Hi,
I have a project going to replace the pedal board connected to my guitar amplifier. I'm hoping to get some help & guidance. Pedal board has 4 buttons.
Button A - controls which one of the 2 channels the amplifier is to switch to. Clean vs Distortion channel
Button B - controls a boost function which elevates volume level
Button C - controls a reverb function
Button D - controls an external effects loop function
Problem is with the buttons B, C & D. This being an analog tube amplifier these buttons do not have a recollection of their last state for each channel. What makes sense for B, C & D in clean channel does not necessarily make sense for the distortion channel. So each time I go between channels I find myself stomping the other buttons to get the B, C & D in the right state which is a bummer...
I rigged up a nice 4 button (momentary) replacement pedal and created a hardware interface to my Uno board to drive 4 relays which will replace the 4 stomp buttons found on the actual pedal. The hardware part of the project is all done and I am able to control the amplifier with the 4 buttons just like its original pedal. I am very pleased with how fast the hardware part of my mission came together. See photos below.
Now for the programming part... I am quite lazy and love reuse, recycle. Thanks for all the sharing in the community. I needed a debounce library to help me handle the momentary switches and also keep track of state such that one press turns function on and next press turns it off.
I came across Carlynorama's excellent button library (ref GitHub - carlynorama/Arduino-Library-Button: This is a library for adding buttons to Arduino projects. It supports events like OnPress and OnRelease.) and very quickly got my 4 button pedal working. Now is the time to implement the memory function such that for each state of Button A, states of buttons B, C & D are stored and recalled when button A state changes.
I opted to use a 2 x 3 matrix array to store the button states that are to be recalled and am able to keep track of them. I am able to set the relays programmatically as well but I came to the conclusion thats not the best way to go. Since the Buttons library is event driven I need to fire off the buttonB.onPressAsToggle() event rather than directly manipulate the relay. Reason for this is the simple On/Off state tracking that the buttons library provides. If I directly manipulate the relay then the library does not know the state of a button has changed so when I actually press that button for another manual change the control actually does not work...
So to cut a long story short, kindly let me know if there is a way to trigger the .onPressAsToggle() event in this library. The public functions don't seem to provide a way to do this and I am not proficient enough to modify the library to do what I need. If there is another library I can use instead kindly point me towards it. Thank you very very much!!!
Photos of my project. Thanks for looking.

