//created by Becca Kilday
//HW 2 Problems 1&2
#define greenLED 10
#define redLED 11
#define yellowLED 12
void setup()
{
pinMode (greenLED, OUTPUT);
pinMode (redLED, OUTPUT);
pinMode (yellowLED, OUTPUT);
Serial.begin(9600);
}
void loop() {
// 0 seconds
digitalWrite (greenLED, HIGH);
digitalWrite (redLED, LOW);
digitalWrite (yellowLED, HIGH); //all lights on
delay (500); // .5 seconds
digitalWrite (greenLED, LOW); //green off after .5s
digitalWrite (redLED, HIGH); //red on after .5s
delay (500); // 1 second
Serial.print (digitalRead (greenLED));
Serial.print (digitalRead (redLED));
Serial.print (digitalRead (yellowLED));
Serial.println (" "); // should be 011
digitalWrite (greenLED, HIGH); //green on after 1s
delay (500); // 1.5 seconds
digitalWrite (greenLED, LOW); //green off after 1.5s
digitalWrite (redLED, LOW); //red off after 1.5s
delay (500); // 2 seconds
Serial.print (digitalRead (greenLED));
Serial.print (digitalRead (redLED));
Serial.print (digitalRead (yellowLED));
Serial.println (" "); // should be 001
digitalWrite (greenLED, HIGH); //green on after 2s
digitalWrite (redLED, LOW); //red off after 2s
digitalWrite (yellowLED, LOW); //yellow off after 2s
delay (500); // 2.5 seconds
digitalWrite (greenLED, LOW); //green off after 2.5s
digitalWrite (redLED, HIGH); //red on after 2.5s
delay (500); // 3 seconds
Serial.print (digitalRead (greenLED));
Serial.print (digitalRead (redLED));
Serial.print (digitalRead (yellowLED));
Serial.println (" "); // should be 010
digitalWrite (greenLED, HIGH); //green on after 3s
delay (500); // 3.5 seconds
digitalWrite (greenLED, LOW); //green off after 3.5s
digitalWrite (redLED, LOW); //red off after 3.5s
}