DEPARTMENT OF
Experiment 3
Student Name: Ujjwal UID: 22BCS10649
Branch: CSE Section/Group: 608-A
Semester:5th Date of Performance: 02/08/2024
Subject Name: IOT LAB Subject Code: 22CSP-329
1. Aim:
To Develop a smart traffic light management system with the help of IoT.
Objective
1. Learn about interfacing.
2. Learn about IoT programming
2.Input/Equipment Used:
o 1 × Breadboard
o 1 × Arduino Uno R3
o 3 × LEDs (Red, Yellow, Green)
o 3 × 220Ω Resistor
o 4 × Jumper
3.Procedure:
▪ Gather parts: Microcontroller, LEDs (red/yellow/green), resistors, breadboard, wires.
▪ Place LEDs: Insert LEDs into the breadboard.
▪ Attach resistors: Connect resistors to the longer leg of each LED.
▪ Wire to microcontroller: Connect resistors to output pins and LEDs' shorter legs to ground.
DEPARTMENT OF
▪ Write code: Program the LED sequence (red, yellow, green).
▪ Upload code: Transfer the program to the microcontroller.
▪ Power up: Turn on the system; LEDs should light up in order.
▪ Test sequence: Ensure LEDs follow the correct traffic light order.
▪ Check connections: Verify all wires and components are securely connected.
▪ Expand project: Add more features, like pedestrian signals or sensors.
4.Connections:
• This is the circuit diagram for the traffic light controller by using Arduino.
• Connect LEDs on the breadboard as Red, Yellow, Green, respectively.
• Connect the negative terminal of the LED and connect the 220 Ohm resistor in series.
• Connect these negative terminals to the ground.
• Connect the positive terminal of the LEDs to the pins 2 to 10, respectively.
• Power the breadboard by using 5V and GND on the Arduino
5.Code:
void setup() {
pinMode(2, OUTPUT); // Red LED
pinMode(3, OUTPUT); // Yellow LED
pinMode(4, OUTPUT); // Green LED
}
void loop() {
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
delay(5000);
// Yellow light on, others off
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
delay(1000);
// Green light on, others off
digitalWrite(2, LOW);
digitalWrite(3, LOW);
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
digitalWrite(4, HIGH);
delay(5000);
// Yellow light on before switching back to red
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
delay(1000);
}
6.Result
7.Conclusion
You should see your LED turn on and off. If the required output is not seen, make sure you have
assembled the circuit correctly, and verified and uploaded the code to your board. This traffic light
controller includes a crosswalk signaling system. The traffic light controller in this system can be
implemented practically, and it could be expanded.