Make Sports Push Buttons with ESP32-C3 to Get You Moving
Push buttons, also known as tactile switches, can be found everywhere from simple lamps, doorbells to large industrial machines. There are so many kinds of push buttons, but I like the arcade push buttons most because they usually have a great tactile, "clicky” feel. I have several arcade buttons in my toolbox, and I always want to make something with them. Lately, I've been working out. One day an idea comes to my mind, can I turn my arcade buttons into a device that helps me do sports? Sounds not bad. I decided to give it a try.
I am going to make 4 sports push buttons, one as a master node with a screen that supports a menu display and the other three as salve nodes. They are all based on ESP32-C3, a micro Beetle controller from DFRobot. It integrates a battery charging management function, which allows us to connect a lithium battery to it as a mobile power supply for the project, or charge the battery from the controller's USB-C port when the battery is low. Also, to make them more interactive, I will add some sound and lighting to the push buttons.
This is what it looks like in the end.
The master node comes with a screen while the slave nodes do not. All parts should be connected as the diagram below.
Buzzer -> Controller’s P6
Button -> Controller’s P5
WS2812 -> Controller’s P0
1. Cut four LEDs from the ws2812 RGB LED strip, and solder one LED to Beetle ESP32-C3. GND goes to GND, VCC to VCC and signal to pin 0.
2. Solder 3.7V lithium battery to C3 controller.
3. Connect the screen and buzzer to the ESP-C3 controller through its Gravity connectors.
4. Use a laser cutter machine to cut out the holes in a plastic case for installing a type-C port, display, switch, and button.
5. Install the arcade button.
6. Attach the power switch, and screen to the case.
7. Fix the battery, buzzer, and Beetle ESP32-C3 inside the case with a hot glue gun.
8. And put the cover on and tighten the screws
Now a sport button of the master node has been done. Repeat the steps above to complete the other three salve nodes. (The salve nodes do not include screens).
Download the codes at https://github.com/DFRobot/SportsButtonESP32C3
Since the master node communicates with the slave nodes by ESP-NOW in this project, the only MAC address of each ESP32-C3 should be obtained so that the master knows which device the message is intended for.
Revise the MAC address to yours and upload the program.
Start to Play
In the program, I set three modes for the buttons. Short press to select mode, press and hold for 2 seconds to confirm or enter the selection menu.
Mode 1- Whac-A-Mole
In this mode, all 4 buttons show green light at first, then one of them changes to red randomly, and we need to hit the red one within a certain time to score. They can be played in various ways.
Mode 2- Relay Race Mode
In this mode, hit the first button, then the second will light up green. Just like a relay race, the green light acts like a baton, which will be transferred one by one among four members repeatedly.
Mode 3- Random Picker Mode
When entering this mode, 4 buttons repeatedly show blue light in order, hit the main button(button with screen), and this time the button whose light turns on in blue will be the picked one.
Or you can only use one button to test how high you can jump.
ESP-NOW delay test:
In the project, the master communicates with the salves by ESP-NOW. To ensure that the NOW protocol meets the communication requirement, here I completed a simple ESP-NOW delay test to record the time for one node transmitting a message to another and receiving a reply. It can be seen that the total delay for transmitting and receiving is about 4ms, which means only a 2ms delay for one-direction transmission, equaling to 1/100s.
Well, that's all for this project. There are so many possibilities for these sports push buttons. Come and try your sports buttons!
Thanks for reading, feel free to leave your opinion about this project.