A classic Snake game implemented on custom hardware, featuring an mbed microcontroller, a breadboard for circuit prototyping, a navigation switch for control, and an LCD screen for display. This project demonstrates embedded programming and hardware interfacing for a retro gaming experience.
- Classic Snake gameplay on a custom hardware setup.
- Control the snake's movement using a navigation switch (up, down, left, right).
- Game display rendered on an LCD screen.
- Implemented on an mbed microcontroller, showcasing embedded system development.
- Modular code structure for easy understanding and modification.
To build and run this project, you will need the following hardware components:
- mbed Microcontroller: (e.g., mbed LPC1768, mbed NXP LPC1768)
- Breadboard: For assembling the circuit.
- LCD Screen: (e.g., 16x2 or 20x4 character LCD, or a graphical LCD if preferred and code adjusted)
- Navigation Switch: A 5-way tactile switch (up, down, left, right, select/push).
- Resistors: (e.g., for LCD contrast, switch pull-ups if needed)
- Jumper Wires: For making connections on the breadboard.
- USB Cable: To power and program the mbed.
- mbed CLI or mbed Online Compiler: To compile and flash the code to your mbed microcontroller.
- mbed OS (or mbed Classic if compatible with your board): The framework used for development.
-
Clone the Repository:
git clone https://github.com/your-username/mbed-Snake.git cd mbed-Snake -
Hardware Assembly:
- Connect your LCD screen to the mbed. Refer to the specific LCD's datasheet and mbed's pinout for correct connections (e.g., RS, E, D4-D7, VCC, GND).
- Connect the navigation switch to digital input pins on the mbed. Ensure you have appropriate pull-up or pull-down resistors if necessary.
- Connect all components to the breadboard and mbed's power and ground rails.
-
Compile and Flash (using mbed CLI):
- Initialize the mbed project:
mbed deploy mbed target <YOUR_MBED_BOARD_NAME> # e.g., NUCLEO_F401RE mbed toolchain GCC_ARM
- Compile the code:
mbed compile
- Drag and drop the generated
.binfile onto your mbed drive when connected via USB, or usembed flashif configured.
- Initialize the mbed project:
Once the code is successfully flashed to your mbed microcontroller and the hardware is correctly assembled:
- Power On: Connect your mbed to a power source (typically via USB to your computer).
- Start Game: The game should automatically start on the LCD.
- Control: Use the navigation switch to steer the snake.
- Up/Down/Left/Right: Change the snake's direction.
- (Optional: If you've implemented a pause/start button, use the center click of the nav switch for that).
- Objective: Guide the snake to eat the food pellets without hitting the walls or its own tail.
Contributions are welcome! If you have suggestions for improvements, bug fixes, or new features, please feel free to:
- Fork the repository.
- Create a new branch (
git checkout -b feature/AmazingFeature). - Commit your changes (
git commit -m 'Add some AmazingFeature'). - Push to the branch (
git push origin feature/AmazingFeature). - Open a Pull Request. This project is licensed under the MIT License - see the LICENSE file for details.