Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Traffic Light System with Pedestrian Crossing

View and Edit Project In Cirkit DesignerImage of Arduino UNO Traffic Light System with Pedestrian Crossing

Circuit Documentation

Summary

This circuit is designed to control a traffic light system with pedestrian crossing functionality using an Arduino UNO microcontroller. The system includes three LEDs for car traffic (red, yellow, green) and two LEDs for pedestrian traffic (red, green). A pushbutton allows pedestrians to request to cross. The car traffic light follows a sequence with defined delays, and when the button is pressed, the pedestrian light turns green, allowing pedestrians to cross.

Component List

  1. Arduino UNO

    • Description: Microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. LED: Two Pin (red)

    • Description: Red LED.
    • Pins: cathode, anode
  3. LED: Two Pin (yellow)

    • Description: Yellow LED.
    • Pins: cathode, anode
  4. LED: Two Pin (green)

    • Description: Green LED.
    • Pins: cathode, anode
  5. Resistor (330 Ohms)

    • Description: Resistor with 330 Ohms resistance.
    • Pins: pin1, pin2
  6. Resistor (10k Ohms)

    • Description: Resistor with 10k Ohms resistance.
    • Pins: pin1, pin2
  7. Pushbutton

    • Description: Pushbutton switch.
    • Pins: Pin 3 (out), Pin 4 (out), Pin 1 (in), Pin 2 (in)

Wiring Details

Arduino UNO

LED: Two Pin (red)

LED: Two Pin (yellow)

LED: Two Pin (green)

Resistor (330 Ohms)

Resistor (10k Ohms)

Pushbutton

Code Documentation

/*
 * This Arduino sketch controls a traffic light system with pedestrian
 * crossing functionality. The system includes three LEDs for car traffic
 * (red, yellow, green) connected to pins 7, 6, and 5 respectively, and
 * two LEDs for pedestrian traffic (red, green) connected to pins 3 and 2
 * respectively. A button connected to pin 8 allows pedestrians to request
 * to cross. The car traffic light follows a sequence with delays defined
 * by DELAY0, DELAY1, DELAY2, and DELAY3. When the button is pressed, the
 * pedestrian light turns green, allowing pedestrians to cross.
 */

#define DELAY0 10000
#define DELAY1 1000
#define DELAY2 2000
#define DELAY3 3000

int ledPinRedCar = 7;
int ledPinOrangeCar = 6;
int ledPinGreenCar = 5;
int ledPinRedWalk = 3;
int ledPinGreenWalk = 2;
int buttonPinLight = 8;
int buttonLightValue = LOW;

void setup() {
  pinMode(ledPinRedCar, OUTPUT);
  pinMode(ledPinOrangeCar, OUTPUT);
  pinMode(ledPinGreenCar, OUTPUT);
  pinMode(ledPinRedWalk, OUTPUT);
  pinMode(ledPinGreenWalk, OUTPUT);
  pinMode(buttonPinLight, INPUT);
}

void loop() {
  buttonLightValue = digitalRead(buttonPinLight);
  if (buttonLightValue == HIGH) {
    digitalWrite(ledPinRedCar, HIGH);
    digitalWrite(ledPinGreenCar, LOW);
    digitalWrite(ledPinOrangeCar, LOW);
    digitalWrite(ledPinRedWalk, LOW);
    digitalWrite(ledPinGreenWalk, HIGH);
    delay(DELAY3);
    digitalWrite(ledPinGreenWalk, LOW);
    digitalWrite(ledPinRedWalk, HIGH);
  } else {
    digitalWrite(ledPinGreenCar, HIGH);
    digitalWrite(ledPinRedCar, LOW);
    digitalWrite(ledPinOrangeCar, LOW);
    delay(DELAY0);
    digitalWrite(ledPinGreenCar, LOW);
    digitalWrite(ledPinOrangeCar, HIGH);
    delay(DELAY1);
    digitalWrite(ledPinOrangeCar, LOW);
    digitalWrite(ledPinRedCar, HIGH);
    delay(DELAY2);
  }
}

This code controls the traffic light system, switching between car and pedestrian lights based on the state of the pushbutton. The car lights follow a sequence with defined delays, and the pedestrian light turns green when the button is pressed, allowing pedestrians to cross.