In this project, we will build a road intersection management system using the STM32F103C6 microcontroller.
Road intersection management involves the strategies and technologies used to control and regulate traffic flow at intersections, ensuring the safe and efficient movement of vehicles, pedestrians, and other road users. The objectives include:
- Optimizing traffic flow
- Minimizing congestion
- Reducing delays
- Enhancing safety
- Improving transportation efficiency
This project will simulate an intersection with multiple traffic lights, countdown timers, and pedestrian support using STM32 GPIOs.
Hardware Requirements
- STM32F103C6 Microcontroller
- 4 × Traffic Light Modules (Red, Yellow, Green LEDs)
- 2 × Mini Traffic Light Modules
- 1 × 7-Segment Display (Common Anode)
Circuit Overview
- Main Traffic Lights: Control straight and right turns (R1, Y1, G1, etc.)
- Left-Turn Signals: Controlled separately (RG1, JG1, VG1, etc.)
- Mini Traffic Lights: For smaller intersections or pedestrian crossings
- 7-Segment Display: Displays countdown (0–9 seconds) during transitions
- Digital I/O only: All signals are managed via STM32 GPIO pins
- Target MCU: STM32F103C6Tx
- Clock Configuration: Set system clock to 8 MHz
- GPIO Configuration:
- PB15, PB0–PB5
→ Traffic Light 1 (R1, Y1, G1, RG1, JG1, VG1)
- PB6–PB11
→ Traffic Light 2 (R2, Y2, G2, RG2, JG2, VG2)
- PB12–PB14, PC13–PC15
→ Mini Traffic Lights 1 & 2 (R3, Y3, G3, R4, Y4, G4)
- PA1–PA6
→ 7-Segment Display (Common Anode).
- Generate initialization code and open in STM32CubeIDE.
- Open the generated project.
- Implement traffic light logic:
- Cycle through Green → Yellow → Red for all directions.
- Include left-turn signals controlled separately.
- Implement countdown timer on the 7-Segment Display:
- Show numbers 5 → 0 seconds during transitions.
- Use HAL_GPIO_WritePin()
or direct ODR
register writes for segment control.
- Build the project and generate the .hex file for simulation.
If you have any questions or suggestions don't hesitate to leave a comment below
Comments