Fiverr gig
$15 β€” I will help you with your project and simulate it for you
Hire me
🌐 IoT Projects

Arduino traffic lights

EmbedLab TeamJanuary 1, 20254 min read
Arduino traffic lights

 This project implements a traffic light system with a countdown timer, designed using an Arduino microcontroller. It controls a sequence of traffic lights (red, yellow, and green) and a 7-segment display counter. Here’s a detailed description:

Features:

  1. Traffic Light Phases:

    • Red Light Phase: The red light is active for 9 seconds, during which a countdown is displayed on a 7-segment display.
    • Yellow Light Phase: The yellow light blinks for 2 seconds before switching to green.
    • Green Light Phase: The green light is active for 9 seconds, with the countdown displayed.
  2. Countdown Display:

    • A 7-segment display shows the countdown from 9 to 0 during the red and green light phases. This is achieved using a 4511 IC, with the display driven by 4 output pins.

Components:

  1. Traffic Light LEDs:
    • Red, yellow, and green LEDs are connected to digital pins 11, 12, and 13 respectively.
    • Controlled using digitalWrite to turn them on or off.
  2. 7-Segment Display:
    • Driven by a 4511 IC, connected to pins 4, 5, 6, and 7.
    • Displays the countdown timer during the active phases of red and green lights.

Workflow:

  1. Setup Phase:

    • Configures the pins for the LEDs and the 7-segment display.
    • Initializes the system with the red light on and the counter set to 9.
  2. Loop Phase:

    • Executes the traffic light phases in sequence:
      • Red Light Phase: Lights the red LED and counts down from 9 to 0.
      • Yellow Light Phase: Blinks the yellow LED for 2 seconds.
      • Green Light Phase: Lights the green LED and counts down from 9 to 0.
    • Repeats the cycle continuously.

Schematic:
Schematic



Code:


Code Highlights:

  • Pin Definitions: Predefined constants improve code readability by labeling the pin numbers.
  • Modular Functions:
    • updateCounter(int value): Updates the display based on the counter value.
    • countdown(int startValue): Handles the countdown logic with a 1-second delay for each decrement.
  • Timing Control: Uses delay() for time intervals, providing precise timing for LED and countdown changes.

Applications:

This project can be used as:

  • A simulation of a basic traffic light system for educational purposes.
  • A starting point for more complex traffic management systems.
ET

EmbedLab Team

Embedded systems engineer and educator. Writes weekly tutorials at EmbedLab to help beginners ship real hardware.

Related projects

Browse all 50+ projects