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

ESP32 and 74HC595 Controlled Traffic Light System with Wi-Fi Connectivity

View and Edit Project In Cirkit DesignerImage of ESP32 and 74HC595 Controlled Traffic Light System with Wi-Fi Connectivity

Circuit Documentation

Summary

This circuit is designed to control two traffic lights using an ESP32 microcontroller and a 74HC595 shift register. The traffic lights are connected through resistors to the shift register, which is controlled by the ESP32. A 5V DC power source is used to power the circuit.

Component List

  1. Traffic Light

    • Pins: Green, Yellow, Red, GND
    • Description: Simulates a traffic light with three LEDs (Green, Yellow, Red).
  2. 74HC595 Shift Register

    • Pins: Q1, Q2, Q3, Q4, Q5, Q6, Q7, GND, VCC, Q0, DS (DATA), OE (Enable), ST_CP (RCLK), SH_CP (SRCLK), MR (SRCLR), Q7' (QH)
    • Description: 8-bit serial-in, serial or parallel-out shift register with output latches.
  3. Resistor (220 Ohms)

    • Pins: pin1, pin2
    • Description: Limits current to the LEDs in the traffic lights.
  4. DC Source 5V

    • Pins: VCC, GND
    • Description: Provides 5V DC power to the circuit.
  5. ESP32 Devkit V1

    • Pins: 3V3, GND, D15, D2, D4, RX2, TX2, D5, D18, D19, D21, RX0, TX0, D22, D23, EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, VIN
    • Description: Microcontroller used to control the shift register and traffic lights.

Wiring Details

Traffic Light 1

Traffic Light 2

74HC595 Shift Register

Resistors (220 Ohms)

DC Source 5V

ESP32 Devkit V1

Documented Code

ESP32 Devkit V1 Code

int latchPin = 13;  // ST_CP
int clockPin = 15;  // SH_CP
int dataPin = 12;   // DS

void setup() {
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(latchPin, OUTPUT);

  Serial.begin(9600);
  Serial.print("Start...");
  setSwitch(B00000000);
}

void setSwitch(byte status) {
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, status);
  digitalWrite(latchPin, HIGH);
}

void loop() {
  setSwitch(B01001000);
  delay(1000);
  setSwitch(B10110111);
  delay(1000);
}

74HC595 Shift Register Code

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

DC Source 5V Code

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

This documentation provides a comprehensive overview of the circuit, including a summary, detailed component list, wiring details, and documented code for the microcontrollers.