Skip to main content
Version: FILS English

Traffic light

A smart traffic intersection with an integrated railway crossing, using sensors to manage vehicle flow and ensure pedestrian safety in real time.

info

Author: Dinu David-Andrei
GitHub Project Link: https://github.com/UPB-PMRust-Students/project-DinuDavidAndrei

Description

This project aims to design and implement a smart intersection integrated with a nearby railway crossing. It uses sensors to monitor traffic and train presence in real time, optimizing vehicle flow and enhancing pedestrian safety. The system automatically adjusts traffic light patterns and activates safety signals when a train is approaching, creating a more efficient and secure environment.

Motivation

The inspiration for this project comes from a real intersection near my grandparents' house, located close to a railway crossing. Over the years, several accidents have occurred there due to poor traffic coordination and the lack of smart signaling systems. This motivated me to design a solution that could prevent such incidents by combining real-time traffic monitoring with intelligent control of both the road intersection and the railway crossing. I believe technology can play a key role in increasing safety and traffic efficiency, especially in high-risk zones like this one.

Architecture

The architecture of the system is modular and designed to ensure both efficient traffic flow and pedestrian safety near a railway crossing. The main components are:

Sensor Input Module Collects data from:

Traffic sensors (IR or ultrasonic) that detect vehicles in each lane

Railway sensor that detects train approach

Pedestrian button (optional) for crossing requests

Control Logic Unit The core decision-making system:

Prioritizes traffic based on congestion level

Temporarily blocks road traffic if a train is detected

Allows safe pedestrian crossings when possible

Traffic Light Controller Translates decisions from the Control Logic into commands for:

LED-based traffic lights (green, yellow, red)

Railway warning lights (e.g., blinking red)

Pedestrian signals (e.g., walk/don’t walk)

Safety Protocol Module Ensures:

All traffic is stopped before train arrival

No conflict between road and railway flows

alt text

Log

Week 5 - 11 May

Received the first hardware components. I ordered a Raspberry Pi Pico 2 and a starter kit. I started exploring how everything works to gain some experience and check if everything functions properly.

Week 12 - 18 May

I realized that hardware debuggers were unavailable for purchase , so I ordered another Raspberry Pi Pico 2 and set it up to work as a debugger. Also placed orders for the sensors, a servo motor, and a traffic light module. Now that everything’s coming together, I have officially started working on the project

Week 19 - 25 May

Hardware

I used two Raspberry Pi Pico boards, a 9V battery, two breadboards, a servo motor, traffic lights (LEDs), and two Hall effect sensor. alt text alt text

Schematics

alt text

Bill of Materials

DeviceUsagePrice
2 Raspberry Pi Pico 2WThe microcontroller and one as a debugger80 lei
Modul cu Senzor Hall YS-277lei x2
Micro Servomotor SG90 90°14lei
Modul cu 3 LED-uri (Roșu, Galben, Verde)4leix5
Kit Plusivo pentru Introducere în Electronică)40lei

Software

LibraryDescriptionUsage
embassyAsync runtime for embedded systemsManages tasks and system operations
embassy-halHardware Abstraction LayerInterfaces with Raspberry Pi Pico 2W hardware
embassy-executorTask executorHandles asynchronous tasks such as sensor polling
embassy-timeTiming moduleDelays and periodic alerts (vibration, LED blinking)
embassy-gpioGPIO managementManages GPIO pins for LED, vibration motor, and button
embassy-syncSync primitivesCoordinates between concurrent tasks safely
defmtLogging and formattingDebug logging with minimal runtime overhead
panic-probePanic handlerHandles runtime panics and reports via RTT
embedded-halAbstraction layerInterfaces with peripherals like I2C and digital IO
rp2040-halHAL for the Raspberry Pi Pico's RP2040 chipDirect access to microcontroller peripherals
mpu9250-driverDriver for the MPU9250 IMU sensorReads posture data from the accelerometer and gyroscope via I2C