This project implements a classic Snake game on an Arduino with an LCD display. Use the buttons to control the snake and try to collect as many fruits as possible without hitting the walls or yourself!
- Arduino board (e.g., Uno, Mega)
- LCD display compatible with the
LCD_Driverlibrary - 5 push buttons
- SPI interface
- Button Connections:
- Right: Pin 2
- Left: Pin 3
- Up: Pin 4
- Down: Pin 5
- Start/Stop: Pin 6
- LCD Connections:
- Use SPI connections as per your LCD's specifications.
SPI.h: For communication with the LCD.LCD_Driver.h: Driver for the LCD display.GUI_Paint.h: For drawing graphics on the LCD.EEPROM.h: To save the highest score.
- Clone the repository or download the ZIP file.
- Install the required libraries (
SPI,LCD_Driver,GUI_Paint,EEPROM) in your Arduino IDE. - Connect the hardware as described in the Wiring section.
- Upload the code to your Arduino board.
- Start the game by pressing the Start/Stop button.
- Use the Up, Down, Left, and Right buttons to control the snake.
- Avoid walls and the snake's body while collecting fruits to increase your score.
To reset the high score stored in EEPROM, uncomment the line EEPROM.write(0, 0); in the setup() function, upload the code, and run it once. Then comment it out again to preserve future high scores.
- Speed Settings: Choose from Easy, Medium, Hard, or Expert.
- Map Selection: Play on different maps - Empty, Border, or Cross.
- Custom Colors: Customize snake and map colors.
Feel free to fork this repository and submit pull requests for improvements or bug fixes.
This project is open-source and available under the MIT License.