Traffic light
A smart traffic intersection with an integrated railway crossing, using sensors to manage vehicle flow and ensure pedestrian safety in real time.
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
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.
Schematics
Bill of Materials
Device | Usage | Price |
---|---|---|
2 Raspberry Pi Pico 2W | The microcontroller and one as a debugger | 80 lei |
Modul cu Senzor Hall YS-27 | 7lei x2 | |
Micro Servomotor SG90 90° | 14lei | |
Modul cu 3 LED-uri (Roșu, Galben, Verde) | 4leix5 | |
Kit Plusivo pentru Introducere în Electronică) | 40lei | |
Software
Library | Description | Usage |
---|---|---|
embassy | Async runtime for embedded systems | Manages tasks and system operations |
embassy-hal | Hardware Abstraction Layer | Interfaces with Raspberry Pi Pico 2W hardware |
embassy-executor | Task executor | Handles asynchronous tasks such as sensor polling |
embassy-time | Timing module | Delays and periodic alerts (vibration, LED blinking) |
embassy-gpio | GPIO management | Manages GPIO pins for LED, vibration motor, and button |
embassy-sync | Sync primitives | Coordinates between concurrent tasks safely |
defmt | Logging and formatting | Debug logging with minimal runtime overhead |
panic-probe | Panic handler | Handles runtime panics and reports via RTT |
embedded-hal | Abstraction layer | Interfaces with peripherals like I2C and digital IO |
rp2040-hal | HAL for the Raspberry Pi Pico's RP2040 chip | Direct access to microcontroller peripherals |
mpu9250-driver | Driver for the MPU9250 IMU sensor | Reads posture data from the accelerometer and gyroscope via I2C |