Twilio held their Signal conference this week at Fort Mason in San Francisco. Each attendee got a HackPack, a Cocoon Slim Backpack with an LED matrix and littleBits. I’ve seen littleBits before, and have been interested in how they make tinkering very easy and basic.
A kid at heart, I ended up getting distracted by it. After installing the IDE, a very basic text editor, I followed the tutorials to print a string of letters. It certainly took me back to the good old days of learning to code with the C-language syntax.
Before I knew it, I was turning lights on and off using a matrix grid. Which sparked an idea. Could I hack together a maze? I could use the value 0 to represent a path (light turned off), the value 1 to represent a wall state (colored red), and the value 2 to represent the moving dot (colored white).
That was pretty simple. But also boring if kept static. It needed to be more…animated. Since there were no extra littleBits like arrow controls or a cloudBit available, I had to do some automated logic. In true hacking spirit and with limited time before the afterparty, I wrote a crude solver. Not the best, but it animated the maze.
This basically picks a random direction and checks to see if the dot can move to that position (a 0 value is an empty spot). If it can, the old position is set to 0 (an empty spot), the new position is set to 2 (the new position). If it can’t, that frame of animation ends up being wasted and unchanged.
It was time for the afterparty so I stopped there. In all, it took around an hour from picking up the bag to getting a brute force maze solver. Of course, this code is ugly and could be improved. It was not meant to be efficient.
The code can be found here.
Instead of a brute force maze solver, my next step would be to connect this to another littleBit to allow user control. A cloudBit could be connected and allow commands to be sent over the network. Being a web developer, I would build a web app that could send left, right, up, down commands.
Even a Twilio SMS implementation could work. Send the command via SMS and it would change the position of the dot. It would be interesting to stick a phone number and instructions on the backpack and see how many people would interact with it.
I would also make it possible to build/load another maze remotely. The web app would have a maze builder, perhaps a way to share it with friends, and then load the maze onto the device.