# button and LED code help

**URL:** <https://forum.midibox.org/t/button-and-led-code-help/16048>\
**Category:** MIDIbox HUIs\
**Created:** [December 6, 2011, 12:16pm UTC](https://forum.midibox.org/t/button-and-led-code-help/16048 "2011-12-06T12:16:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![eptheca](https://forum.midibox.org/user_avatar/forum.midibox.org/eptheca/32/183_2.png) [@eptheca](https://forum.midibox.org/u/eptheca)\
**Post date:** [December 6, 2011, 12:16pm UTC](https://forum.midibox.org/t/button-and-led-code-help/16048/1 "2011-12-06T12:16:04Z")

</div>

I’m bulding a MB64, and have a problem I need help with

I need the buttons and leds to work so that only the last pressed button’s LED light up

[http://discourse.midibox.org/t/topic/13888](http://discourse.midibox.org/t/topic/13888)

this works sort of, but it affects all types of button press, not only “onOnly” like I would like it to

also I would like it to only affect the buttons within the same shift register

I use 2 SR, the first have 8 buttons with it’s LEDs, and all 8 have an “onOnly” message

I would like these to only light the last pressed

in the second SR I have 3 buttons with “Toggle” message that I would like to light LED when pressed and turn off LED when pressed again

and I have 4 buttons with “onOnly” message that I would like the LEDs to light up only the last pressed of these 4

Is it possible to have the code from the post I linked to to only work for “onOnly” buttons and only within the same SR

I would really appreciate some help with this, my coding “skills” are limited to editing ☹

---

<div class="post-metadata">

**Author:** ![eptheca](https://forum.midibox.org/user_avatar/forum.midibox.org/eptheca/32/183_2.png) [@eptheca](https://forum.midibox.org/u/eptheca)\
**Post date:** [December 13, 2011, 10:18am UTC](https://forum.midibox.org/t/button-and-led-code-help/16048/2 "2011-12-13T10:18:24Z")

</div>

here is a short video of how the buttons and LEDs work now

https://www.youtube.com/embed/SS9ZE4ncdWM?feature=oembed&wmode=opaque

sorry, I can’t embed

TK, please can you help me out

I have built the hardware and ordered the frontplate ☹

here is the code I have changed

```
;; (button value stored in TMP1)

MB64_BUTTON_OnOnly 

        ;; when on: send button value defined in dump 

        ;; when off: send nothing 

        BRA_IFSET TMP1, 0, ACCESS, MB64_BUTTON_NotifyChangeEnd 

        ;; turn off SR1 8 LEDs 

    SET_BSR MB64_BUTTON_VALUES_SR0+0  

    setf MB64_BUTTON_VALUES_SR0+0

    SET_BSR MB64_BUTTON_VALUES_SR0+1  

    setf MB64_BUTTON_VALUES_SR0+1 

        ;; save status of button 

        rcall MB64_BUTTON_Hlp_SaveStat 

        rgoto MB64_BUTTON_Send

```

thanks in advance

---

<div class="post-metadata">

**Author:** ![ilmenator](https://forum.midibox.org/user_avatar/forum.midibox.org/ilmenator/32/10_2.png) [@ilmenator](https://forum.midibox.org/u/ilmenator)\
**Post date:** [December 13, 2011, 10:23am UTC](https://forum.midibox.org/t/button-and-led-code-help/16048/3 "2011-12-13T10:23:41Z")

</div>

> here is the code I have changed
> 
> ;; (button value stored in TMP1)  
> MB64\_BUTTON\_OnOnly   
> ;; when on: send button value defined in dump   
> ;; when off: send nothing   
> BRA\_IFSET TMP1, 0, ACCESS, MB64\_BUTTON\_NotifyChangeEnd   
> ;; turn off SR1 8 LEDs   
> SET\_BSR MB64\_BUTTON\_VALUES\_SR0+0   
> setf MB64\_BUTTON\_VALUES\_SR0+0  
> SET\_BSR MB64\_BUTTON\_VALUES\_SR0+1   
> setf MB64\_BUTTON\_VALUES\_SR0+1   
> ;; save status of button   
> rcall MB64\_BUTTON\_Hlp\_SaveStat   
> rgoto MB64\_BUTTON\_Send

That’s slightly unreadable… could you reformat?

---

<div class="post-metadata">

**Author:** ![eptheca](https://forum.midibox.org/user_avatar/forum.midibox.org/eptheca/32/183_2.png) [@eptheca](https://forum.midibox.org/u/eptheca)\
**Post date:** [December 13, 2011, 10:32am UTC](https://forum.midibox.org/t/button-and-led-code-help/16048/4 "2011-12-13T10:32:20Z")

</div>

sorry about that

was trying to embed the youtube video, and it all went pearshaped

---

<div class="post-metadata">

**Author:** ![ilmenator](https://forum.midibox.org/user_avatar/forum.midibox.org/ilmenator/32/10_2.png) [@ilmenator](https://forum.midibox.org/u/ilmenator)\
**Post date:** [December 15, 2011, 8:46pm UTC](https://forum.midibox.org/t/button-and-led-code-help/16048/5 "2011-12-15T20:46:07Z")

</div>

Uuuh, I realize that you are coding in Assembler… that is actually my weak side, so I cannot help you here. I guess we need the **Assembler gurus to the rescue**?
