//Where the switch buttons are attached (Global vatiables)
byte greenButtonPin = 5;
byte blueButtonPin = 4;
//Where the LEDs are attached
byte redLedPin = 3;
byte greenLedPin = A1;
byte blueLedPin = A2;
//Runs only once
void setup(){
//Set the buad rate & initialise the serial monitor
Serial.begin(9600);
//Set the pin mode, HIGH or LOW, INPUT or OUTPUT, button or LED
pinMode(greenButtonPin, INPUT);
pinMode(blueButtonPin, INPUT);
pinMode(redLedPin, OUTPUT);
pinMode(greenLedPin, OUTPUT);
pinMode(blueLedPin, OUTPUT);
}
void loop(){
//Check the state of the button pin & assign the value to a varaible (Local variables)
boolean buttonStateOne = digitalRead(greenButtonPin);
boolean buttonStateTwo = digitalRead(blueButtonPin);
//Send the value for the buttonstate variable to the serial port
Serial.print("Green Button = ");
Serial.println(buttonStateOne);
Serial.print("Blue Button = ");
Serial.println(buttonStateTwo);
digitalWrite(redLedPin, HIGH);
delay(500);
digitalWrite(redLedPin, LOW);
delay(500);
digitalWrite(greenLedPin, LOW);
digitalWrite(blueLedPin, LOW);
if (buttonStateOne > 0) digitalWrite(greenLedPin, HIGH);
if (buttonStateTwo > 0) digitalWrite(blueLedPin, HIGH);
}