In this tutorial, I will teach you how to create an LED game with very little code or experience! I had this idea for a while and finally got around to creating it. It's a fun game that reminds us all of the arcade games. There are other tutorials that I will link for further references. This can be made within an hour of hard work and is worth the effort :)
WS2812B LEDS x24
Momentary push button
Step 1: Watch the Demo
Step 2: Find Any Type of Frame
In this case, I used a picture frame. Building one is always an option but I wanted to quickly finish this project. My project has 20 LEDs that wrap around the frame. However, this number can always be changed based on preference or desired power consumption.
Step 3: Programming
This program is not the most efficent.. but it does the job perfectly. The game has five different gamestates. Gamestate zero represents the idle state until the button is pressed. The other gamestates represents which level the player is on. To counter the debounce of the button, I use the function millis() instead of delay(). This way the game can still run while the button processes.
To tweak the speed to the preference, lowering the ledSpeed variable will increase the speed. The speeds are in order of the difficulty.
Step 4: Wiring and Soldering
This project can either be powered by a 5v cord running to the Arduino Nano or from a 3 AA battery pack to make it portable.
Drill a hole for the momentary push button or have it separate from the frame. Connect one side to ground and the other side to pin 4.
(Optional)-Connect the battery pack with the switch on the 5v line to the VIN and Ground pins on the Arduino Nano. Make sure the signal is 5v and the output can handle powering the Arduino and the LED's. To increase the longevity of batteries, put a brightness capacity on the LED's.
Connect both sets of LED's to the 5v rail on the Arduino and connect the Grounds. Finally, follow the Din lines to the desired pins on the Arduino.
Step 5: Hot Glue and Secure
I used a lot of hot glue and a Zip Tie to secure the wires. Try to cover any sharp objects and secure the wires firmly. Hands may be holding this.
Step 6: Another Reference
Participated in the
1 Hour Challenge