/*
  Button
 
 Turns on and off a light emitting diode(LED) connected to digital  
 pin 13, when pressing a pushbutton attached to pin 2. 
 
 
 The circuit:
 * LED attached from pin 13 to ground 
 * pushbutton attached to pin 2 from +5V
 * 10K resistor attached to pin 2 from ground
 
 * Note: on most Arduinos there is already an LED on the board
 attached to pin 13.
 
 
 created 2005
 by DojoDave <http://www.0j0.org>
 modified 30 Aug 2011
 by Tom Igoe
 
 This example code is in the public domain.
 
 http://www.arduino.cc/en/Tutorial/Button
 */

// constants won't change. They're used here to 
// set pin numbers:
     // the number of the pushbutton pin
const int redSwitch = 5;
const int blueSwitch = 3;
const int greenSwitch = 4;
const int yellowSwitch = 6;
const int purpleSwitch = 7;
const int ledPin = 13;
const int redline = 1;
const int blueline = 2;
int pass = 0;
      // the number of the LED pin

// variables will change:
int blueState = 0; 
int redState = 0;
int greenState = 0;
int yellowState = 0;
int purpleState = 0; // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(redSwitch, INPUT);   
  pinMode(yellowSwitch, INPUT); 
  pinMode(greenSwitch, INPUT); 
  pinMode(blueSwitch, INPUT); 
  pinMode(purpleSwitch, INPUT);   
  pinMode(ledPin, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(10, INPUT);
  // initialize the pushbutton pin as an input:
  Serial.begin(9600);    
}

void loop(){
  // read the state of the pushbutton value:
  Serial.println(blueState);
  blueState = digitalRead(blueSwitch);
  greenState = digitalRead(greenSwitch);
  purpleState = digitalRead(purpleSwitch);
  yellowState = digitalRead(yellowSwitch);  
  redState = digitalRead(redSwitch);
  pass = digitalRead(10);


  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:

  if (blueState == HIGH && purpleState == HIGH && redState == HIGH ) {     
   if(greenState == LOW && yellowState == LOW){
    delay(3000);
    digitalWrite(ledPin, HIGH);  
    if (pass == HIGH)
    {
    digitalWrite(11, HIGH);
    }
    else
    {
     digitalWrite(11, LOW); 
    } 
  } 
  
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW); 
    digitalWrite(11, LOW);
  }
  }
  else {
    digitalWrite(ledPin, LOW); 
    digitalWrite(11, LOW);
}
}
