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

Arduino-Powered Traffic Light Control System with RFID and Ultrasonic Sensors

View and Edit Project In Cirkit DesignerImage of Arduino-Powered Traffic Light Control System with RFID and Ultrasonic Sensors

Circuit Documentation

Summary

The circuit in question is designed to interface an Arduino Nano with an RFID-RC522 module and to connect an Arduino Mega 2560 with multiple HC-SR04 Ultrasonic Sensors and Traffic Lights. The Arduino Nano is used to control the RFID-RC522 module, while the Arduino Mega 2560 manages the ultrasonic sensors for distance measurement and controls the traffic lights based on the sensor inputs. The circuit includes resistors for current limiting purposes with the traffic lights.

Component List

Microcontrollers

Sensors

Actuators

Passive Components

Wiring Details

Arduino Nano

Arduino Mega 2560

RFID-RC522

HC-SR04 Ultrasonic Sensors

Traffic Lights

Resistors

Documented Code

Arduino Nano Code

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

}

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

}

Arduino Mega 2560 Code

#include<TimerOne.h>

// ... (initialization and pin assignments)

void setup(){
  // Setup code including pin mode settings and serial communication
}

void loop()
{
  // Main loop code including reading button states and ultrasonic sensor values
}

// Interrupt function to read ultrasonic sensor values
void softInterr()
{
  // Reading from ultrasonic sensors and storing the distance
}

// Functions to control the traffic light signals
void signal1Function()
{
  // Control logic for signal 1
}

void signal2Function()
{
  // Control logic for signal 2
}

void signal3Function()
{
  // Control logic for signal 3
}

void signal4Function()
{
  // Control logic for signal 4
}

// Functions to handle the case when there are no vehicles
void signal01Function()
{
  // Control logic for no vehicles at signal 1
}

void signal02Function()
{
  // Control logic for no vehicles at signal 2
}

void signal03Function()
{
  // Control logic for no vehicles at signal 3
}

void signal04Function()
{
  // Control logic for no vehicles at signal 4
}

// Function to set all LEDs to a low state except red ones
void low()
{
  // Set all LEDs to low except red ones
}

This code snippet is a simplified representation of the actual code used in the Arduino Mega 2560. It includes the setup of pins, the main loop with logic for reading sensor values and controlling traffic lights, interrupt service routines for ultrasonic sensors, and additional functions for traffic light control.