Traffic Light
Traffic Light
Traffic Light
Wiring Diagram
Wiring Diagram
Getting Ready for the Program
Getting Ready for the Program
Green Light
Green Light
When the green light is on what is the state (HIGH or LOW) of the LED's?
When the green light is on what is the state (HIGH or LOW) of the LED's?
Green LED: HIGH (On)
Yellow LED: LOW (Off)
Red LED: LOW (Off)
Yellow Light
Yellow Light
When the yellow light is on what is the state (HIGH or LOW) of the LED's?
When the yellow light is on what is the state (HIGH or LOW) of the LED's?
Green LED: LOW (Off)
Yellow LED: HIGH (On)
Red LED: LOW (Off)
Red Light
Red Light
When the red light is on what is the state (HIGH or LOW) of the LED's?
When the red light is on what is the state (HIGH or LOW) of the LED's?
Green LED: LOW (Off)
Yellow LED: LOW (Off)
Red LED: HIGH(On)
Try it yourself
Try it yourself
Before looking at the finished code below try and write it yourself first!
Before looking at the finished code below try and write it yourself first!
void setup()
void setup()
declare what pins you are using with pinMode()
declare what pins you are using with pinMode()
void loop()
void loop()
write the main code here by using digitalWrite() and delay()
write the main code here by using digitalWrite() and delay()
use the light states above to help you
use the light states above to help you
Program
Program
void setup() {
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
}
void loop() {
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
delay(1000);
digitalWrite(8, LOW);
digitalWrite(9, HIGH);
digitalWrite(10, LOW);
delay(1000);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
delay(1000);
}
Final Quiz
Final Quiz