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
DocumentationQuick start guide, installation instructions, component requirements, and usage examples.
📥 Download📄 Tutorial (Markdown)
DocumentationComplete in-depth tutorial with logic, safety rules, state diagrams, and detailed explanations.
📥 Download🌐 Interactive Tutorial (HTML)
DocumentationBeautiful web-based tutorial with animations, visual demos, and color-coded sections.
👁️ View Online🐍 Python Code - Two-Way Intersection
two_way_traffic_simple.py
BeginnerSimple sequential state machine. Perfect for learning the basics! Clear and easy to understand.
📥 Downloadtwo_way_traffic_generator.py
IntermediateElegant Python generator approach using gpiozero's source parameter. More Pythonic!
📥 Download🚧 Python Code - Three-Way Intersection
three_way_traffic_paired.py
IntermediateT-junction with paired operation. Main road (A+B together) vs side road (C).
📥 Downloadthree_way_traffic_sequential.py
IntermediateSequential operation where each direction takes turns: A → B → C → repeat.
📥 Download🎯 Advanced Examples
traffic_simulator.py
BeginnerNo-hardware simulator! Test your logic with emoji lights (🔴🟡🟢) before building the circuit.
📥 Downloadtraffic_oo_controller.py
AdvancedProfessional object-oriented design with classes, enums, logging, and scalable architecture.
📥 Download🚀 Quick Start
- Start with the Interactive Tutorial (click the button at the top)
- Download and run traffic_simulator.py to see the logic in action
- Read the README.md for circuit setup instructions
- Build your circuit on a breadboard
- Try two_way_traffic_simple.py first
- Progress to more advanced examples as you learn!