# 2 * 3 buttons

Hi

I create a 6 button and 6 leds project following this link (radio button)
https://forum.arduino.cc/index.php?topic=288716.0 And it works

I like to split up the 6 in to 2 groups (2*3 button)
The buttons in group 1 must be indepenend of group 2 and visa versa

Any hint/link in this direction?

Joop

What exactly do you want the 6 buttons and 6 LEDs to do ?

Using the radiobutton reply#12 from the link, the easiest explainable method would recreate the functions denoted by 'A' group or 'B' group - as provided in the example below:

boolean timeoutA(unsigned long *marker, unsigned long interval) {
//stuff here
}

boolean timeoutB(unsigned long *marker, unsigned long interval) {
// stuff here
}

boolean butndownA(char button, unsigned long *marker, char *butnstate, unsigned long interval) {
//stuff here
}

boolean butndownB(char button, unsigned long *marker, char *butnstate, unsigned long interval) {
//stuff here
}

void loop{
if (butndownA(digitalRead(button1), &bcount1, &bstate1, 10UL )) {
//stuff here
}

if (butndownA(digitalRead(button2), &bcount2, &bstate2, 10UL )) {
//stuff here
}

if (butndownA(digitalRead(button3), &bcount3, &bstate3, 10UL )) {
//stuff here
}

if (butndownB(digitalRead(button4), &bcount4, &bstate4, 10UL )) {
//stuff here
}

//... so on and so forth

UKHeliBob:
What exactly do you want the 6 buttons and 6 LEDs to do ?

Group 1
If button 1 is pressed led 1 is on 2,3 off
If button 2 is pressed 1,3 off and 2 will be on
If button 3 is pressed 1,2 is off and 3 on

Group2
Same for 4,5 and 6 but independend of group 1

Later on it will control a matrix of relais (2 groups)

No you dont need two buttonDown() functions. Just one will do it.

That function debounces the buttons. It turns the real-world complexity of a button into something that is useful for the Arduino. You need to keep that part.

Look at the code inside loop() in either reply 10 or 11 in that thread. Look at what button 1 does. It turns on LED 1 and it turns off ALL the others. You should change it so that button 1 turns off ONLY 2 and 3. It won't affect 4 5 and 6.

MorganS:
No you dont need two buttonDown() functions. Just one will do it.

That function debounces the buttons. It turns the real-world complexity of a button into something that is useful for the Arduino. You need to keep that part.

Look at the code inside loop() in either reply 10 or 11 in that thread. Look at what button 1 does. It turns on LED 1 and it turns off ALL the others. You should change it so that button 1 turns off ONLY 2 and 3. It won't affect 4 5 and 6.

Ok simple and it works.

But I guess it isn't the way to go in my small project.

Next step is to add 4 relais and those are controlled by group1 or group2 switches and will be different in setting.
The group will be select by an external input (high/low)

Joop