0

modifying the Button Board
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

modifying the Button Board

by grjmmr on Mon Jun 12, 2017 12:56 pm

I am building a stomp box that will run some RGB lights. Before people jump up and say I am reinventing the wheel and why not use existing devices, the reason is, is I am attempting to integrate 3 different ideas (one being a hand held device) that would be easier for me to run off of a stomp switch. Basically when I get finished it will look like a guitar processor but will run the lights in my drums.

So I would like 8 buttons at the top of the box Red, Green, Blue, Orange (RG), Teal (BG), Purple (RB), White (RGB) and Off/Blackout. Can I use

https://learn.adafruit.com/remote-contr ... io/esp8266

The problem I am having is how would I code something like Orange? I assume I would need to modify the "if" statement, so would it be something like

}
if (ButtonRead > 750 && ButtonRead < 900) {
current = 1,2;

so I am sending out current on both Red and Green. Or is there an easier way to do this and I am just making to much of it.

Thanks in advance
grjmmr
 
Posts: 17
Joined: Sun Jul 06, 2014 12:48 pm

Re: modifying the Button Board

by adafruit_support_carter on Mon Jun 12, 2017 1:40 pm

The project you linked uses a resistor ladder fed into an analog input to read the buttons. So you would first need to add the additional resistors/buttons. Then figure out what ADC reading ranges correspond to your setup/button presses and add the necessary if statements.

adafruit_support_carter
 
Posts: 2073
Joined: Tue Nov 29, 2016 2:45 pm

Re: modifying the Button Board

by grjmmr on Mon Jun 12, 2017 2:44 pm

I understand I have to add more buttons and figure out the range, no problem. I am just really bad at coding. The question is, when I modify the "if" statement to create the tertiary colors, if I put "current = 1,2; will it provide current both to Red led and the Green led thus creating the Orange effect or do I need to code it differently to get 2 different led's to light up at the same time
grjmmr
 
Posts: 17
Joined: Sun Jul 06, 2014 12:48 pm

Re: modifying the Button Board

by adafruit_support_carter on Mon Jun 12, 2017 3:03 pm

The variable current (not the flow of electrons) just holds the current value of the buttons press state. These are just given the integer values 0,1,2,3. Four button, four values. You would just expand the if statement to include you other buttons. The basic template is something like:
Code: Select all | TOGGLE FULL SIZE
if (ButtonRead > BUTTON_1_RANGE_MIN && ButtonRead < BUTTON_1_RANGE_MAX) {
  current = 1;
}
if (ButtonRead > BUTTON_2_RANGE_MIN && ButtonRead < BUTTON_2_RANGE_MAX) {
  current = 2;
}
// etc. Add as many as you want.

You would add eight if blocks for eight buttons and give them values 0,1,2,3,4,5,6,7 (or whatever you want). Those integers are sent to the receiving end which then does the actual turning on of the LEDs. See the switch statement here:
https://learn.adafruit.com/remote-contr ... o/led-code
and modify the digitalWrites() as needed.

adafruit_support_carter
 
Posts: 2073
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.