In my previous post I wrote about being transfixed by the Line Wobbler at the Video Games exhibit that runs through February at the Victoria & Albert Museum in London. In this follow-up I’m going to try and document how Tim, Meredith, and I actually built a clone of the Line Wobbler called Twang (“an Arduino-based 1D dungeon crawler”) and you can find the code at this Github repo. I followed the list of things to buy from the Github repo, and they were right on. Here’s the specific pieces I bought for reference:
I would add to that list the following few things:
I think that’s all, but I may add to the above if I remember anything else. The whole thing will cost you around $85 US.
The other things you need to get are the required libraries for the Arduino that are listed on the Github page, I have them all downloaded in this zip file for easy, one-click downloading, but they can all be found online as well.
Twang Joystick Enclosure
Beyond the hardware and the software, you will also need to 3D print an enclosure. We actually bought a Ultimaker3 printer last week, so it was a perfect test for our new workhorse 3d printer—that machine is awesome. We (royal, this was all Tim) modified the Twang joystick enclosure a bit, and that was a wild process (more on that shortly). You can also explore the buildlog.net remix of the Twang joystick which is very cool.
Twang joystick remix by Buildlog.net
So, once you have all the pieces and have printed the enclosure you should be ready to start building your game. One of the cooler part for me was Tim’s ability to customize the Twang joystick to adjust for a different speaker size as well as increase the depth of the gyroscope casing to fit the wires.
First mod was reducing the thickness of one section of the cover plate so that the speaker would fit cleanly in the enclosure. To do this Tim essentially removed a layer of the coverplate using Tinkercad, and it worked perfectly. You can see in the bottom corner we left a small triangle of the original depth to keep the coverplate fastened.
The first task we tackled early in the week was learning how to solder the requisite wires on the gyroscope. Meredith and I actually worked through a practice soldering kit given this as our first time, and after about an hour we felt comfortable enough soldering the pins to the gyroscope board. There may be a more efficient way to solder given you will only be using the VCC, GND, SCL, SDA, and INT pins, but we decided to solder the entire pin connector so we could use the Arduino wires to just slide them on cleanly. That said, this is also why we needed to reprint the casing for the gyroscope that sits on top of the doorstop, it was not deep enough if you include the pins like we did.
Getting the piece soldered was a big deal for us. I did say before I began this build: “Can’t I get someone to do the soldering for me?” Not very Maker-compliant thinking 🙂
Once the pins were soldered we color-coded each of the gyroscope connections as shown above based on the colored wires we had.
As you can see from the image above the gyroscope goes into the top of the joystick that sits on the doorstop. So, with the gyroscope soldered and placed in the joystick casing and the wires run through the doorstop it was time to plug them into the Arduino board. Thankfully buildlog.net once again bailed us out by making an awesome graphic illustrating where all the pins go (note they use an alternative color scheme than ours):
You can see that the SCL and SDA can go where he has them sitting before the AREF, or in ports 20 and 21 which are labeled accordingly. The INT pin goes in port 2 and the Vcc pin can use the 3V power port (he has 5V listed, but I saved that for the LEDs and both worked—probably cause we used fewer LEDs) and the ground goes to GND. Once all those are plugged in you should see the green power light on the gyroscope.
If that worked you should be able to move on the the LED lights. I messed up here, which cost us some time. The LEDs will have five wired, a power and ground wire (red and black respectively that are not pictured above) and the LED specific wires (data (green), clock (red), and black (ground)) that are pictured above. The clock (red) goes into port 3, and green (data) into port 4, and LED ground (black) goes into a GND port. As I mentioned before, it is recommended to use a different 5V power supply for the LED lights, but possibly because we only used 300 we did not need to, so we plugged the power and ground for the LED strip into the Arduino board as well, but your mileage may vary on this one.
Once you have the LED wired you can then wire the gyroscope using the diagram above and the 3V power port as I specified.
The speaker is the final bit, and I have yet to solder ours, but this is basically two Arduino wires that you plug into ports 11 and 12. This was crucial for us cause I did not think to plugin it in while we were troubleshooting the LED lights I had in the wrong ports, but once Tim had the idea we could establish the game was working given the sounds played. So if you have the gyroscope hooked up, the LED lights plugged in and have loaded the code and libraries all to no avail, be sure to connect the speakers.
Now we are ready to download the Arduino IDE interface and start loading libraries and see if this thing works (note you can do this when ever you want, but there is really no need until the LED lights and gyroscope are hooked up). The Arduino IDE is basically your desktop app to upload libraries and edit and upload Arduino code (which is written in simplified C/C++). The first thing to do is plug the USB a to USB B convertor in your computer and go to Tools–>Port to see if you see the Arduino in the USB port. If you do you can start uploading the libraries.
The screenshot above is how you upload the various zip files of the required dependencies for Twang. Go to Sketch–>Include Library–>Add .ZIP Library. Once you have uploaded all the required libraries you can then upload the Twang files using the Open icon (upward arrow) and find the Twang.ino file in the TWANG folder with all the requisite code (it is the TWANG.zip file in the dependency and core files I linked to above) on your desktop or where ever you are keeping it.
At this point the code should be ready to be uploaded to the Arduino using the right-facing Arrow icon and it will then be pushed to the Arduino. You can use the Arduino IDE to compile and re-upload the code using the right-facing arrow (upload) and the check mark (compile) icons. These will be useful given you may need to make some edits. We had to change the number of LEDs, for example. We got a strip with 300 LEDs, so we needed to edit the following line of the Twang code from 1000 300 in the // LED Setup area::
After that, we needed to define the type of LED lights we’re using, this is another detail I missed that Tim picked up on. In the //Fast LED section you can change the type of LEDs from APA102
FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, LED_COLOR_ORDER>(leds, NUM_LEDS);
to WS2812B, which is the type of LED lights we bought (which are cheaper):
FastLED.addLeds<WS2812B, DATA_PIN, CLOCK_PIN, LED_COLOR_ORDER>(leds, NUM_LEDS);
If you have APA102 lights no need to make this change, and there may be others varieties of LEDs, so be sure to check which type of lights you ordered to make the correct edit here.
OK, I think that is everything, and the sheer thrill of getting this running was worth the time. And the game plays quite well. I am gonna try and add more LEDs to the string and see if I can get the lives indicator working, so I may add updates and follow-ups, but you can see the came play in the videos below. If you to try and make this thing, I do not think you will regret it—and it could make a fun light display for the holidays 🙂