top of page
Writer's pictureSanskruti Ashtikar

How to Create a Traffic Light Controller in TinkerCAD

Updated: Sep 14

Traffic lights are essential components in managing traffic flow at intersections. Building a traffic light controller is a fantastic project for learning about microcontrollers and sequential logic. With TinkerCAD, you can simulate a traffic light system using an Arduino and a few basic electronic components. In this article, we'll walk you through creating a traffic light controller circuit that mimics the operation of a standard traffic light.



Components Required for Arduino Traffic Light Project:


  • Breadboard (Small)

  • Arduino Uno R3

  • 3 LEDs (Red, Yellow, Green)

  • 3 x 220-ohm resistors

  • Jumper wires


Circuit Connections for Traffic Light project using TinkerCAD


Step 1: Setting Up the Breadboard and Arduino


  1. Open TinkerCAD: Log in to your TinkerCAD account and navigate to the "Circuits" section.

  2. Create a New Circuit: Click on "Create new Circuit" to open the workspace where you'll build your traffic light controller.

  3. Place the Breadboard and Arduino: Drag a small breadboard and an Arduino Uno R3 onto the workspace. Position them next to each other for easy connections.


Step 2: Connecting the LEDs


  1. Place the LEDs: Drag three LEDs (red, yellow, and green) from the components panel and place them on the breadboard. Arrange them in a vertical line, with the red LED at the top, the yellow LED in the middle, and the green LED at the bottom.

  2. Connect Resistors: Connect a 220-ohm resistor to the anode (longer leg) of each LED. The other end of each resistor should connect to an empty row on the breadboard.

  3. Connect the Cathodes to Ground: Connect the cathode (shorter leg) of each LED to the ground (GND) rail on the breadboard using jumper wires.



Step 3: Wiring the Circuit to the Arduino


  1. Connect the Red LED to Pin 13: Use a jumper wire to connect the other end of the resistor from the red LED to digital pin 13 on the Arduino.

  2. Connect the Yellow LED to Pin 12: Similarly, connect the yellow LED to digital pin 12 on the Arduino.

  3. Connect the Green LED to Pin 11: Connect the green LED to digital pin 11 on the Arduino.

  4. Connect the Ground Rail to Arduino: Finally, connect the ground rail (negative rail) of the breadboard to one of the GND pins on the Arduino.


Code for Traffic Light Controller Project


  • Open the Code Editor: To open the code editor, click on the "Code" button at the top right of the TinkerCAD interface.

  • Choose Text-Based Coding: Switch to "Text" to write the code in Arduino's C/C++ language.

  • Write the Code:


void setup() {

  pinMode(13, OUTPUT); // Red LED

  pinMode(12, OUTPUT); // Yellow LED

  pinMode(11, OUTPUT); // Green LED

}

void loop() {

  // Green light on for 5 seconds

  digitalWrite(11, HIGH);

  delay(5000);

  digitalWrite(11, LOW);

  // Yellow light on for 2 seconds

  digitalWrite(12, HIGH);

  delay(2000);

  digitalWrite(12, LOW);

  // Red light on for 5 seconds

  digitalWrite(13, HIGH);

  delay(5000);

  digitalWrite(13, LOW);

}

This code controls the traffic light sequence: the green light stays on for 5 seconds, followed by the yellow light for 2 seconds, and finally the red light for 5 seconds. The loop repeats indefinitely.



Simulating the Traffic Light Project using TinkerCAD


  1. Start Simulation: Click on the "Start Simulation" button to see your traffic light controller in action. The LEDs should light up in sequence—green, yellow, and red—mimicking the operation of a real traffic light.

  2. Adjusting the Timing: You can change the delay times in the code to adjust how long each light stays on. For instance, increasing the delay for the red light will extend the red light's duration.


Troubleshooting Tips


  • LEDs Not Lighting Up? Double-check your wiring, particularly the connections between the resistors and the Arduino pins.

  • Wrong LED Sequence? Ensure the correct LEDs are connected to the corresponding pins (13, 12, and 11).


Conclusion


You’ve successfully built a traffic light controller using TinkerCAD and an Arduino! This project is a great introduction to working with microcontrollers and understanding how timing and sequencing work in real-world applications. With this knowledge, you can expand the project by adding more LEDs for a pedestrian crossing signal, incorporating sensors to detect traffic, or even designing more complex traffic light systems.


TinkerCAD's user-friendly interface makes it easy to experiment with different components and circuit designs, allowing you to learn and create at your own pace. Keep exploring and innovating as you continue your journey in electronics.


Happy tinkering!



Order Electronics Projects


Want us to guide you through your project or make the project for you? Click on the button below or reach out to us via Call/WhatsApp at (+91) - 7600948607


You can -


  • Order Basic Electronics Projects

  • Order Embedded Systems Projects

  • Order IoT Projects

  • Order FPGA Projects

  • Order VLSI Projects

  • Order Image Processing Projects

  • Order Matlab Projects

  • Order TinkerCAD Projects

  • Order Proteus Projects


Click on the button below to fill out the project inquiry form -




Create Various Projects


Check out our Free Arduino Projects Playlist - Arduino Projects 

Check out our Free Raspberry Pi Projects Playlist - Raspberry Pi Projects 

Check out our Free TinkerCAD Projects Playlist - TinkerCAD Projects 

Check out our Free IoT Projects Playlist - IoT Projects 

Check out our Free Home Automation Projects Playlist - Home Automation Projects 

Check out our Free NodeMCu Projects Playlist - NodeMCu Projects 



Follow us -


Please do follow us i.e. #learnelectronicsindia to get daily updates about new blogs, videos, courses, products, offers, competitions, quizzes, and Internship Opportunities.





56 views0 comments

Related Posts

See All

Comments


bottom of page