#include "WProgram.h" // declare variables: int switchPin = 2; // digital input pin for a switch int switchPin2 = 5; int switchPin3 = 12; int yellowLedPin = 3; // digital output pin for an LED int redLedPin = 4; // digital output pin for an LED int greenLedPin = 11; int switch_1_state = 0; // the state of the switch int switch_2_state = 0; int switch_3_state = 0; int hits = 0; int prevState = 0; void setup() { pinMode(switchPin, INPUT); // set the switch pin to be an input pinMode(switchPin2, INPUT); // set the switch pin to be an input pinMode(switchPin3, INPUT); // set the switch pin to be an input pinMode(yellowLedPin, OUTPUT); // set the yellow LED pin to be an output pinMode(redLedPin, OUTPUT); // set the red LED pin to be an output pinMode(greenLedPin, OUTPUT); } void loop() { // read the switch input: delay(500); switch_1_state = digitalRead(switchPin); switch_2_state = digitalRead(switchPin2); switch_3_state = digitalRead(switchPin3); if ((switch_2_state == 1) && (switch_3_state == 1)) { if( hits == 3 ) { digitalWrite(yellowLedPin, HIGH); // turn on the yellow LED digitalWrite(redLedPin, HIGH); // turn on the red LED digitalWrite(greenLedPin, LOW); // turn off the green LED hits = 0; } else { digitalWrite(yellowLedPin, LOW); // turn off the yellow LED digitalWrite(redLedPin, LOW); // turn off the red LED digitalWrite(greenLedPin, HIGH); // turn on the green LED } /*if(prevState != switch_1_state){ hits++; prevState = switch_1_state; }*/ if(switch_1_state == 1){ hits++; } } else { // if the switches are all off, then LEDs are all off digitalWrite(yellowLedPin, LOW); // turn off the yellow LED digitalWrite(redLedPin, LOW); // turn off the red LED digitalWrite(greenLedPin, LOW); // turn on the red LED } }