Button toggle on, toggles other 3 buttons off PBF4

@_d4ydream Toggle A which is pressed (on) and Toggle B, C & D which are unpressed (off). I want to set the experience so that when Toggle B is pressed, Toggle A, c & D are unpressed (off) and visa versa.

In the off state, they should all have different colours. ON state should be red. Perhaps blinking red.

@
_d4ydream - is this something you can perhaps program?

All the best,
Alex

1 Like

I assume you want it so only one button can be on? Pushing one button enables it while disabling the others?

Should be really straightforward. I’m indisposed of this evening though. If nobody else replies by the time I’m off work tomorrow, I’ll post some code. :slight_smile:

Yes, only one on at a time.

Thanks!
I’m using it for an interactive music/dance improvisation performance. The buttons will choose which set of instruments are record enabled/activated in Ableton. And the midi control surface will be a 3m diameter carpet with conductive fabric. So dancing will play the instruments!

1 Like

Very cool!

I’m just off to work so I’ll take a look later today, time permitting. I’m otherwise pretty open tomorrow. My partner is off to do Xmas baking with her mom and sister. Loads of spare time tomorrow :slight_smile:

1 Like

Sounds good! Excited to see what you come up with :slight_smile:

1 Like

I’ve got the LED behavior setup on my BU16. If I push a button it lights up and all others are set to off. However, for the MIDI side of things, are you going to:

  • Push a button and send a value or group of values.

while

  • Making all other buttons send a ‘0’ value to turn off their respective parameters.

I need a bit more detail on what the unselected buttons should do.

Edit: This is essentially done. I’m just not sure of the full behavior you need. I can set it up a couple of ways so let me know if you’re using ‘Exclusive Arm’ in Ableton or if you need Grid to turn off arm for you when you arm another track. I’ve setup the latter as I want to do some things myself but all of this is easily modified.

Cheers!

This part I’ve not accommodate but it should be easy enough to setup. I’m just turning all other LEDs off except the active button. It’s very clear which button is active this way. No need to flash an LED.

Hi! Great. I am not using exclusive arm no.

I will be sending one CC at 127 per button for ON. So 4 different CC’s total.
And yes, 0 value for OFF.

1 Like

Day got away from me. I’ll post code snippets tomorrow at some point during my workday.

I have this setup on a BU16 but you can use the following code on the buttons on your PBF4. On the ‘System’ element ‘Setup’ tab, delete the current contents and add the following to a ‘Code’ block:

active = nil
last = 9
function init_element(i)
    if i <= 9 then
        element[i]:button_value(2)
        event_trigger(i, 3)
    else
    end
end

I don’t use ‘Utility’, ‘Midi rx’, or ‘Timer’ on the ‘System’ element so I generally delete all code on those tabs.

On each of the button elements ‘Setup’ tab, delete all code blocks, add in a ‘Code’ block, then overwrite any of the default code with the following:

local red, gre, blu = led_default_red(), led_default_green(), led_default_blue()
self.cc, self.ch, self.ei = (module_position_x() + 1) + self:element_index(), 0, self:element_index()
led_color(self.ei, 1, red, gre, blu, 1)

You can change the variable assignments for ‘red’, ‘gre’, and ‘blu’ to the actual RGB values you want to use by replacing their assignments to actual RGB values instead of the ‘led_default_red()’ etc. functions. I use the following tool when doing this:

RGB Color Picker

The same can be done for the MIDI CC and channel. Replace the formulae with the CC and channel you want to use for that button.

On the ‘Button’ tab, delete all of the action blocks, add in a ‘Code’ block, then overwrite any of the default code with the following:

local bv, bs = self:button_value(), self:button_state()
if bv == 2 and active ~= self.ei then
    element[last]:button_value(0)
    midi_send(self.ch, 176, self.cc, 0)
    led_value(self.ei, 1, 0)
elseif bs == 127 and bv == 127 and self.ei ~= last then
    midi_send(self.ch, 176, self.cc, 127)
    led_value(self.ei, 1, 80)
    init_element(last)
    last = self.ei
elseif bs == 0 then
end

I’m not using the ‘Timer’ so I delete the code block on that tab.

The way this code works is, when you press a button, it sends the assigned CC with a value of 127, sets itself to active and flags itself as the last button to have activated. If you press the same button again, nothing happens. When you press another button, it sends its assigned CC with a value of 127, assigns it self as active, calls a function to have the last button used sends its CC with a value of 0 then sets itself to last.

I setup my code so that all button LEDs are off unless active. It’s super easy to easy to see what it and what isn’t active. If you want all buttons to be lit at all times while the active button flashes, it’s easy enough to do but it’s more code to add.

Cheers!

:slight_smile:

I’m just stealth posting my radio button code here, you guys might find it useful. It is used in the BU16 MCU profile as well to turn off LEDs of toggle buttons.

function radio(active, begin, over)
    for i = begin, over do
        if active ~= i then
            element[i]:button_value(0)
            led_value(i, 1, 0)
        end
    end
end

Call radio() first on button press events so that it will check and turn off the other buttons between the [begin;over] range.

1 Like