This interactive game and artwork is partly inspired by seeing the joy of youngsters playing with another of my interactive works, and partly by finding a broken set of Rock Band drums.
The game is simple. There are three drums. A red one, a green one and a blue one. One of them will randomly become activated, a light on the floor will move towards it, and it will start animating for up to 4-seconds. The player has that time to hit that drum, but the longer they leave it the less time the following player will have. If a player does not hit it in time they get a failure sound and the game restarts. If they hit it in time there is a “success” sound played and another drum, or perhaps the same drum, is selected to go next.
There is no scoring and no limit game time. It is designed to be an optical spectacle for anyone watching and will be rewarding to anyone playing no matter how good or bad their timing is. While intended to be a group activity I found while testing it can be fun to play on your own.
If you want a live introduction to what I created then that is here. A video of the project running with sound is towards the bottom of this page.
In answer to the obvious questions... Q) Why the hat? A) Why not? Q) Why the lab coat? A) Because Science!
Design OverviewThis build is by far the most complicated project I have documented on Hackster, and unusually for me it is not a project I see someone duplicating exactly. All the commented/documented source code is here, and this section can be used as a set of build instructions, but I will try and keep this write up manageable and avoid going into micro detail. Feel free to reach out if you need any more information in the future.
The project is split into two halves. Driving it all is the central control that consists of a Raspberry Pi 5 with a DMX controller, Bluetooth speaker system, and an ESP8266 microcontroller to manage the communications. Second there are the drums that each run on an ESP8266 microcontroller.
The control of the game is managed by the Raspberry Pi centrally, but as timing is critical to playing the game each round is managed locally in the active drum. A random drum receives a message to start at the desired speed, and then the drum takes over the game, and then responds with the result. There is a timeout if the drum of communications fails but this is not required in normal operation.
CommunicationsIn order to avoid wires trailing all over the room and causing trip hazards I wanted to use wireless communication. There are several options, but in order to keep things simple I used ESP-Now, a packet based wireless protocol baked into the ESP microcontrollers.
While there are a few potential issues with using wireless communication this is more than adequate for this project. I would however want to use a hard wired solution for a more serious installation. The code has been written with this in mind and can be protected to use RS-485 or CAN if needed. It is also worth noting that this implantation does not implement any encryption or authentication.
The full structure of the over the air datagrams is documented in the drum firmware source code from line 66, but I will summarise it here. At the start of the packet is a header so we can identify what is our data and what is from other projects using the same channel. We then have source and destination fields so we know who sent the packet and where it was sent to. There is a speed flag to send the desired speed of the next go, and a hit field for the drum to tell the central controller if the player was successful in hitting the drum at the same time.
The Drums - HardwareAs mentioned before the drums are a recovered from an old Rock Band game, but in reality they are just a rubber disk with a piezo transducer glued to the bottom. When you hit them they produce a small voltage the microcontroller can detect. You can see the enclosures I made with various scraps of wood and pipe, but you are not likely to have the same scraps so my recommendation is not to copy my build, but use it as inspiration and do better.
As for the electronics however, this is something you can recreate easily and use my firmware as it is. You can either use the schematic or follow these build instructions and photos.
First you will need the microcontroller module, a buck converter, a 12v LED strip and a battery connector. I am using crocodile clips for my battery. You could use a 5v LED strip and a 5v power supply, but I opted for 12v as that is the voltage of most LED Neon strips.
Next we need to set the output voltage of the buck converter to 5v (+/- 0.5v). Now we can assemble it as shown in the photographs. Remember the schematic is also on listing if you prefer to work from that, and the pin assignments are also documented in the code.
The LED Neon strip is a little more tricky to solder to than most LED strips and I did make a couple of errors. With that in mind you may want to cut the length after soldering on the wires. I also suggest making the cut line by routing the strip where it should be to avoid cutting it to the wrong length, and so you know what is the in and what is the out end. Another tip is I found clipping a hold in the bottom of the strip helped a lot with getting the wires routed after attaching them.
The firmware is attached and mostly documented in the comments. It is a non-blocking loop that uses the reactive time to work out what is happening when. Think of it as a time based state machine.
Functionally when the central controller wants to hand control to the drum and start the round it sends a message. This sets the start time and stores the speed to run the round at. The animation continues based on the duration since that start time, and if it goes over a failure message is sent back to the central controller to continue the game. If the player hits the drum at that time a success message is sent back, and if the drum is hit at any other time a message is sent to do nothing more than play a sound effect.
The only configuration you will need to do is edit the MAC addresses of the three drums you are using. Uploading the software will send the MAC address from a new module to the serial port if you don't already know it.
Central Controller - HardwareThis is as basic as a Raspberry Pi, with a USB DMX controller and an ESP8266 connected via the USB port. In my build I downloaded and printed a case for both the Raspberry Pi and the ESP8266. There is also a DMX light that I will cover in more detail below. There is nothing complicated here. Just plug it all in.
The Raspberry Pi is running Raspberry Pi OS with Python 3 installed (as it is by default). I suggest using Thonny to get up and running, and if you have moved beyond that then you likely don’t need my help here. Q Light Controller Plus (QLC+) also needs installing, but again I will cover that below.
The source code is documented in the code using comments so I will only give a high level overview here. After setup the software picks a drum colour it sends a UDP packet to move the DMX light, and sends a message to the ESP6266 gateway to hand control over to the selected drum ( startRandomGame() ). It then enters a loop where it waits for any responses from the drums, plays a sound when it hears something, and exits the loop when appropriate ( readGameResponce() ).
The one setting you may need to edit in the Python code is GATEWAY_PORT (line 16) if you have any other serial devices on your computer. Depending on the DMX controller you use this may appear as one. If ttyUSB0 does not work then try ttyUSB1.
Central Controller - Gateway FirmwareAs we are using ESP-Now and not wifi we need to use an ESP microcontroller as a bridge / gateway. The approach I have taken is to keep things simple and the gateway firmware just listens for a message to send on the serial port and sends it over ESP-Now, and anything received over the air is sent back to the serial port. Any processing to do with the messages is done in the Python code.
It is worth noting that the ESP8266 based microcontroller modules are great, but have some limitations at times. One being that the analogue read (that we need to detect a hit on the drum) prevents the wireless communication at the same time. My workaround to this is to only sample the analogue input in every 6 milliseconds. This means we will not miss an input as any pulse will be longer than that, but we might miss a wireless message. Instead of implementing a complicated transmission control system I simply send the message to the drum three times over 8 milliseconds. This results in at least one of the messages being received even in the worse scenario.
Central Controller - SoundFor copyright reasons I can not distribute the sound effects here, and you may want to use your own, but the ones I used are available free from Pixabay. Direct links are Background, Hit, Success, and Fail.
These sounds are played using the PyGame library. The background sound loops indefinitely, and the other sounds are triggered by the drum messages.
You may notice I catch the KeyboardInterrupt exception at line 123 of the Python code. This is so I can turn off the DMX light and stop the background sound when CTRL-C is pressed. This was a cunning move to save my sanity in development as without it the sound kept playing after interrupting the programme.
Central Controller - DMXUsing the DMX light to track to the next drum is not essential to the gameplay but a nice little extra. I was lucky in my timing and this one I am using is a £35 refurb stock bargain, but they can be purchased new for under £120.
As there are many DMX controllers, and existing software solutions for driving them, I decided to use the free and open source Q Light Controller Plus (QLC+) to do the hardware interfacing. My code sends a UDP packet to QLC+ based on the Art-Net protocol.
Installation is simple. From the Raspberry Pi terminal run…
sudo apt install qlcplus…and then start Q Light Controller Plus from the menu.
We next need to get some numbers so the controller knows where to point the light. To do this we select the “Simple Desk” tab from the tabs at the bottom of the window, and move the sliders until the light is pointing in the correct direction for the red drum, is the correct colour, and at the correct intensity. Which fader does what depends on the DMX light used and the mode it is in, but this will be documented in your light’s manual. When it looks correct make a note of the settings and repeat for the blue and green drums.
Now create a file called dmxvals.csv in the same directory as the Python programme. This comma separated file needs four lines. Line 1 is for a home position that is currently not used, so leaving it as a “0” will be fine. Then a line for the red, green and blue settings. Remember to put the values in, including any unused valuers in between, but any trailing values will automatically be 0 so there is no need to pad it out.
Now in QLC+ Select the “Inputs/Outputs” tab and select “ArtNet 1:127.0.0.1” as the input, and “DMX USB 1:FT232R” (or your DMX controller if you are using another one) as the output. This means that any command we send from the Python code is mapped thought to the DMX hardware.
If you look closely in the source I have used an IP6 destination address (“::1”) and not an IP4 one (“127.0.0.1”). This is because of a bug in the current release of QLC+ where the Art-Net receiver binds to the IP6 local host address and not an IP4 one, despite what the software says. There are workarounds, and it no doubt it will be fixed in the future, but this just works for now. I have made the code check if the address is IP4 or IP6 so you can just change the address in the future, or hard code a different IP address if you want to run QLC+ on a different machine, or if you have a hardware Art-Net compatible controller.
DemonstrationWell that is the project done and documented. It works, and hopefully it is not immodest to say it works well. Here is a video of it in action.
Hopefully it will be used in an exhibition in August and it may well come out at future Maker Fests, hacker camps, or similar events.
If you make something based on it please do let me know. It is always nice to know when I have had a positive impact on something.










_t9PF3orMPd.png?auto=compress%2Cformat&w=40&h=40&fit=fillmax&bg=fff&dpr=2)




Comments