Need help with button combinations

Okay, so I have my arduino wired up with 6 buttons (digital pins 2-7) lighting up 6 LEDs (pins 7-13). When I press each button it successfully lights up its corresponding LED. This is for a science museum showing how different chemicals in fireworks light up different color. So if you press button 1 with A chemical, it will light up blue. Button 2 with chemical B will light up Red and so on. I now need to add combinations, so for example if you press button 1 it will light up LED 1, press button 2 it will light up LED 2, but if you press 1 and 2 together it lights up only LED 3, purple. Does anyone know how I can program these combinations? I hope I explained that well enough, if not I will be happy to clarify further. My code is attached below.

Fireworks_25.ino (3.28 KB)

I told you it is very easy. Wire the Leds and the rest of your buttons

#define Num_of_Buttons 3

boolean buttons[Num_of_Buttons] = {2,3,4};

byte LED_byte = 0;
void setup()
for(byte i = 0; i < Num_of_Buttons; i++)
  pinMode(2+i, INPUT);

void loop() {
  for(byte i = 0; i < Num_of_Buttons; i++) // cycle through button array.
    bitWrite(LED_byte, i, digitalRead(2+i)); // 2 = first button, 2 + i = cycle through all the buttons. 

I uploaded this code but it wont do anything. Also, its not letting me pick the combinations that I want.

The code is doing something, the question is what? The code is using the serial monitor, which is set at a certain baud rate, to display a certain variable. You need to set up your Leds to react to that variable, but first you need to see that variable.

Your serial monitor might not be set to the baud rate in the code, but you can change it to do so, either the monitor itself or the code.

A very nice approach to reading these buttons and interpreting combinations would be to set an index = 0 at the top of the loop, then as, each button is read, increment the index with 1, 2, 4, 8, 16, or 32, depending on which button(s) are down. Thus each possible button combination translates to a unique integer from 0 to 63, and then you can use a switch statement to perform the correct action for each combination. I've done something like this using 6 resistors of values from 50, 100, ..., 1600, to read a single analog input to an UNO and sort out each combination of 64 possible DIP switch combinations.

Hope this helps.

John Doner