Hardware
The following components are required for this project:
1. Seeed Studio XIAO ESP32C3
2. NeoPixel Ring - 16 x RGB LED (WS2812B)
3. Three big buttons module
Software
1. Install Arduino IDE 2.0+ for Arduino
2. Install ArduProf lib 1.3+
3. Install Arduino DebugLog lib
4. Install Arduino FastLED lib
5. Clone this github-esp32c3-tiny-game code by "git clone https://github.com/teamprof/github-esp32c3-tiny-game"
Build and run firmware on XIAO ESP32C3
1. Clone this repository by "git clone https://github.com/teamprof/github-esp32c3-tiny-game"
2. Launch Arduino and open the project
3. Wiring XIAO ESP32C3, LED and buttons as below

4. Build and upload the firmware in Arduino IDE.
If everythong goes smooth, you should see the following in "Monitor"

Picture of Game stop

5. Click button "Game" to start a new game

6. Each player clicks its corresponding button. The LEDs labeled ‘Green’ and ‘Blue’ represent player 1 and player 2, respectively.
7. Once a player wins, the LED shows its corresponding color. Picture of Game player1 win
Picture of Game player2 win

LED colors on different state
+------------------+------------+------------------------------+
| LED color | state | status |
+------------------+------------+------------------------------+
| red on (all) | game stop | no winner |
| red blink (all) | game pause | no winner |
| green on (all) | game stop | player1 win |
| green on | game pause | player1 position |
| blue on (all) | game stop | player2 win |
| blue on | game pause | player2 position |
| green/blue blink | game start | player1 and player2 position |
+------------------+------------+------------------------------+
Code explanation in high level
There are two tasks in this project. The first one is "QueueMain" and the second one is "ThreadGame".
"QueueMain" handles hardware events, such as when a player clicks a button, while "ThreadGame" handles game events, such as advancing a player’s position. "RoundLed" is responsible for LEd indication.
Please refer to source code for details
Demo
Video demo is available on [esp32c3-tiny-game]()