This shows you the differences between two versions of the page.
iothings:proiecte:2023sric:esp32_snake_game [2024/05/27 20:56] robert.coman1205 |
iothings:proiecte:2023sric:esp32_snake_game [2024/05/29 22:32] (current) robert.coman1205 [ESP32 Snake Game] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== ESP32 Snake Game ====== | ====== ESP32 Snake Game ====== | ||
+ | {{:iothings:proiecte:2023sric:comanrobert_proiect_iot.zip|}} | ||
+ | |||
+ | [[https://www.youtube.com/watch?v=59ZyiAMcoxQ|Demo]] | ||
===== 1. Introduction ===== | ===== 1. Introduction ===== | ||
The aim of this project is to implement the famous 'Snake' game in an IoT environment. The game is powered by an ESP-WROOM-32S microcontroller, which is connected to an 8x8 RGB matrix used for display and a joystick with which the user can interact to control the movement. The project leverages multiple key concepts and technologies used in the IoT and embedded design worlds, such as system interrupts, driving signals through pins, reading analog values and converting them to digital values, logging data to the flash memory (through SPIFFS), and using Bluetooth to allow the user to interact with the board and perform various actions through sending commands. | The aim of this project is to implement the famous 'Snake' game in an IoT environment. The game is powered by an ESP-WROOM-32S microcontroller, which is connected to an 8x8 RGB matrix used for display and a joystick with which the user can interact to control the movement. The project leverages multiple key concepts and technologies used in the IoT and embedded design worlds, such as system interrupts, driving signals through pins, reading analog values and converting them to digital values, logging data to the flash memory (through SPIFFS), and using Bluetooth to allow the user to interact with the board and perform various actions through sending commands. | ||
Line 13: | Line 16: | ||
{{:iothings:proiecte:2023sric:rgb_matrix.png?200|}} | {{:iothings:proiecte:2023sric:rgb_matrix.png?200|}} | ||
* RGB 8X8 LED matrix (WS2812B) | * RGB 8X8 LED matrix (WS2812B) | ||
+ | * Pins used: Pin 27 (for communication), 5V and GND | ||
{{:iothings:proiecte:2023sric:joystick.png?200|}} | {{:iothings:proiecte:2023sric:joystick.png?200|}} | ||
* Biaxial joystick module with push-button | * Biaxial joystick module with push-button | ||
+ | * Pins used: Pins 36 (ADC1_0) and 39 (ADC1_3) for X-Y movement, pin 25 for button interrupt handling, 3V3 and GND | ||
==== b. Software ==== | ==== b. Software ==== | ||
Line 21: | Line 26: | ||
* **iot_project.ino** - main source file containing the setup (initialization of all components) and loop (which handles game logic and BLE communication). | * **iot_project.ino** - main source file containing the setup (initialization of all components) and loop (which handles game logic and BLE communication). | ||
* **game.ino** - contains the game logic along with its rendering on the RGB matrix. | * **game.ino** - contains the game logic along with its rendering on the RGB matrix. | ||
- | * **logging.ino** - offers the capability of writing data to the API. It offers an API specific for the game, which allows performing actions related to the game (writing scores for a certain user in flash, creating new user, listing scores users, etc.). | + | * **logging.ino** - offers the capability of writing data to the filesystem. It offers an API specific for the game, which allows performing actions related to the game (writing scores for a certain user, creating new user, listing scores for any user, listing users sorted by their highest score, etc.). |
* **bluetooth.ino** - handles the Bluetooth communication with the user and parses and executes the commands received from the user. | * **bluetooth.ino** - handles the Bluetooth communication with the user and parses and executes the commands received from the user. | ||
Line 97: | Line 102: | ||
===== 3. Conclusions and final result ===== | ===== 3. Conclusions and final result ===== | ||
- | TODO | + | The implementation of the project can be seen in the following pictures and in the attached video on the top of the page. |
+ | |||
+ | {{:iothings:proiecte:2023sric:esp_32_snake_game_1.jpg?200|}} | ||
+ | {{:iothings:proiecte:2023sric:esp_32_snake_game_2.jpg?200|}} | ||
+ | |||
+ | |||
+ | |||
+ | The project achieves the proposed objectives: implementing the classic Snake game on a LED matrix and using Bluetooth communication and SPIFFS flash logging to enhance its functionality. The features have been tested and work successfully. | ||
+ | |||
+ | Improvements can be made, though, especially in the hardware-related zone. For example, there are times where the wires do not make full contact with the RGB matrix on the breadboard, which translates to power cutting off and turning the LEDs off, or having random LEDs turning on. To fix this, the matrix has to be adjusted a little bit, until you see it is working again and it must be ensured the matrix stays in a fixed position in order to reduce any possibility of this occuring. | ||
+ | Another improvement is regarding the code size, which consumes close to 90% of the available code memory. This is because the project includes multiple libraries (Bluetooth, SPIFFS, AdaFruit_NeoPixel, etc) that take high amounts of space. | ||
===== 4. References ===== | ===== 4. References ===== | ||
*https://ocw.cs.pub.ro/courses/iothings/laboratoare/2022/lab1 | *https://ocw.cs.pub.ro/courses/iothings/laboratoare/2022/lab1 |