🚦 Multi-Way Traffic Light Control

Complete Educational Project for Raspberry Pi

Welcome to the Traffic Light Control Project!

Learn how to build and program realistic two-way and three-way traffic light systems using Raspberry Pi, Python, and gpiozero.

📖 View Interactive Tutorial 📥 Download README

🎯 What's Included

  • Complete Tutorial - Learn the logic, safety rules, and state diagrams
  • 6 Python Examples - From beginner to advanced implementations
  • Hardware Simulator - Test your logic without building circuits
  • Two-Way & Three-Way - Multiple intersection configurations
  • Professional Code - Object-oriented design patterns included

📚 Documentation

📄 README.md

Documentation

Quick start guide, installation instructions, component requirements, and usage examples.

📥 Download

📄 Tutorial (Markdown)

Documentation

Complete in-depth tutorial with logic, safety rules, state diagrams, and detailed explanations.

📥 Download

🌐 Interactive Tutorial (HTML)

Documentation

Beautiful web-based tutorial with animations, visual demos, and color-coded sections.

👁️ View Online

🐍 Python Code - Two-Way Intersection

two_way_traffic_simple.py

Beginner

Simple sequential state machine. Perfect for learning the basics! Clear and easy to understand.

📥 Download

two_way_traffic_generator.py

Intermediate

Elegant Python generator approach using gpiozero's source parameter. More Pythonic!

📥 Download

🚧 Python Code - Three-Way Intersection

three_way_traffic_paired.py

Intermediate

T-junction with paired operation. Main road (A+B together) vs side road (C).

📥 Download

three_way_traffic_sequential.py

Intermediate

Sequential operation where each direction takes turns: A → B → C → repeat.

📥 Download

🎯 Advanced Examples

traffic_simulator.py

Beginner

No-hardware simulator! Test your logic with emoji lights (🔴🟡🟢) before building the circuit.

📥 Download

traffic_oo_controller.py

Advanced

Professional object-oriented design with classes, enums, logging, and scalable architecture.

📥 Download

🚀 Quick Start

  1. Start with the Interactive Tutorial (click the button at the top)
  2. Download and run traffic_simulator.py to see the logic in action
  3. Read the README.md for circuit setup instructions
  4. Build your circuit on a breadboard
  5. Try two_way_traffic_simple.py first
  6. Progress to more advanced examples as you learn!