Project Title:
Traffic Light Control Game
Overview:
The Traffic Light Control Game is an interactive simulation where a car on the p5.js screen reacts to traffic light LEDs controlled by an Arduino Uno. Players use keyboard arrow keys to control the car’s movement, adhering to basic traffic light rules:
- Red LED: Stop the car.
- Green LED: Move the car.
- Yellow LED: Serves as a warning with no required interaction.
The game emphasizes real-time interaction between physical components and digital visuals, showcasing the integration of hardware and software.
Key Features:
- Traffic Light Simulation:
- Red, yellow, and green LEDs simulate a real-world traffic light.
- The lights change sequentially in predefined intervals.
- Interactive Car Movement:
- Players use arrow keys to control the car:
- Up Arrow: Move forward.
- Down Arrow: Stop the car.
- The car’s behavior must match the traffic light signals.
- Players use arrow keys to control the car:
- Real-Time Feedback:
- If the car moves during a red light or stops during a green light, a buzzer sounds to indicate a violation.
- Game Over:
- If repeated violations occur, the game ends with a “Game Over” screen.
Objective:
The goal is to follow traffic light rules accurately and avoid violations. The game offers an educational yet engaging experience, simulating real-world traffic scenarios.
Technical Components:
Hardware:
- Arduino Uno:
- Controls traffic light LEDs and buzzer.
- 3 LEDs:
- Represent traffic lights (red, yellow, green).
- Buzzer:
- Provides auditory feedback for rule violations.
- Resistors:
- Ensure proper current flow for LEDs and buzzer.
- Breadboard and Wires:
- Connect and organize the components.
Software:
- Arduino IDE:
- Manages traffic light logic and sends the light states to p5.js via serial communication.
- p5.js:
- Displays the car and road.
- Handles player input and real-time car behavior based on the light states.
Implementation Plan:
1. Traffic Light Control:
- The Arduino controls the sequence of LEDs:
- Green for 5 seconds.
- Yellow for 3 seconds.
- Red for 5 seconds.
- The current light state is sent to p5.js via serial communication.
2. Car Movement:
- The p5.js canvas displays:
- A road with a car.
- The current traffic light state using on-screen indicators.
- Arrow keys control the car’s position:
- Right Arrow: Move forward.
- Up Arrow: Stop.
3. Feedback System:
- If the car moves during a red light or doesn’t move during a green light:
- A buzzer sounds via Arduino.
- Violations are logged, and after three violations, the game ends with a “Game Over” message.
Expected Outcome:
- Players will interact with a dynamic simulation where their actions on the keyboard directly correspond to the car’s behavior.
- The integration of physical LEDs and buzzer with digital visuals will create a seamless interactive experience.
- The project demonstrates a clear understanding of hardware-software integration and real-time interaction design.
Extensions (STILL THINKING ABOUT IT):
- Scoring System:
- Reward correct responses with points.
- Dynamic Difficulty:
- Reduce light duration intervals as the game progresses.
- Enhanced Visuals:
- Add animations for the car (e.g., smooth movement, brake effects).