LAB Arduino UNO
Manip1 :Traffic light
Start your experiment with one LED. The second manipulation will be figure 1 for the traffic
light.
Fig1 : Traffic light Tri colours
Components for circuit
• Arduino board
• A board
• USB cable
• 3 resistors of 220Ω
• Green LED
• Red LED
• Orange LED
Code Tricolor light
Light the three LEDs as follows: Orange ON for 1 second Red ON for 1 second Green ON for 1 second
Circuits :
- Red LED in pin 2 – Orange LED in pin 3 – Green LED in pin 4
const int Red = 2;
const int Orange = 3;
const int Green = 4;
// The code is executed on time
void setup()
{
// indicate that the LED pins are OUTPUT
pinMode(Red, OUTPUT);
pinMode(Orange, OUTPUT);
pinMode(Green, OUTPUT);
}
1
// The code is executed in loop
void loop()
{
digitalWrite(Orange, HIGH);
delay(1000);
digitalWrite(Orange, LOW);
digitalWrite(Red, HIGH);
delay(1000);
digitalWrite(Red, LOW);
digitalWrite(Green, HIGH);
delay(1000);
digitalWrite(Green, LOW);
}
Manip2 : Crossroads Lights
Programming - Run red/orange/green lights of crossroads
The tricolour lights operate as follows: red light illuminated for 4s, orange light illuminated for 1s and
green light illuminated for 4s. At the start and after an orange light, all lights are red for 1s. The cycle
must repeat indefinitely
Fig2 Crossroads Lights