As my first applied and fully implemented Arduino project, I decided to create an 8 by 8 pixel LED display mounted on my cap for high school graduation. I had been working along with the official starter kit and an Arduino Uno for the previous six months, and I felt confident that I could handle this project. I initially researched charlieplexing (which I still struggle to understand) but then multiplexing, which I deemed efficient enough, seeing as I planned to solder the entire project to a proto shield and had no need for room for expansion.
On a midnight during winter break, I found a dirty piece of scrap countertop material in my home (I expected this to be a rough prototype at the time), which I cut to the size of a grad cap. I snuck a hand drill into my room, as my parents wouldn't approve of my poor sleeping habits, and proceeded to drill 128 holes into a fairly dense sheet of plastic and wooden veneers. A couple of hours later, I was pleased to find that the few various LED's I had from my starter kit fit into the holes fairly well. After I was satisfied by my half-filled and mismatched array, I ordered 100 yellow LED's on eBay for a few bones. I thought this would be a nice and bright color that would match my school colors of blue and gold, and also, because I'm going to the University of Michigan this fall.
At this point I could finally fill up the whole array with matching LED's. I was looking to build it as thinly as possible, and I found myself unreasonably set on using Aluminum tape as a was to connect all of the leads that were to be folded down on top of it. I spent hours slicing thin strips of this tape, only to find that I had a hard time getting reliable connections from the hat to the Arduino. I ended up doing this twice over, but it was only more frustrating the second time.
My initial (and scrapped) design. I unfortunately
didn't think to take any pictures of my final design
before I sealed it up to the cap. It's essentially the
same, but with soldered wires instead of tape.
didn't think to take any pictures of my final design
before I sealed it up to the cap. It's essentially the
same, but with soldered wires instead of tape.
A quick and dirty connection to the Arduino
using two stripped Ethernet cables.
Eventually I decided on the most obvious design and used long hookup wire to solder together each row and column together. This went much more smoothly and I don't recall having any connection issues this time. I created 16 wires, but stripped them completely and placed shrink tubing where the wires would intersect, and placed a small amount of hot glue at these locations to ensure nothing would ever short out. This has proven to work pretty well.
My next obstacle came with connecting the hat to the Arduino. I really wanted to have a setup in which everything could be disconnected. I realized that IDE ribbon cables have plenty of pins (multiplexing resulting in needed 16) and male connectors are really easy to make, since I could just use a long row of headers. I ordered some cheap perfboard and cut out a small piece on which I soldered the 16 cables sticking out of the square. they were connected to right-angle headers on the perfboad, and This was all covered with shrink tubing.
As for the Arduino side, I initially created a prototype on my protoshield and its built in breadboard. This included the MPU-6050, a cheap accelerometer/gyroscope/temperature sensor, a button (for interruptions) and, because I had one analog pin left, a small potentiometer. This was then soldered to another protoshield at an overnight school party while all the underclassmen were spooning.
I was very satisfied by the setup I had at this point, so I began working on the software. I made several animations by simply creating different for loop layouts, and things like spirals were especially fun to program. All of the software uses an onLED method which simply takes the coordinates of the pixel to be turned on, and the duration of time that the LED is left on. Because of this, that means that all the animations I wrote never turn on more than one LED at a time. This was certainly possible, but I was interested in the consequences and challenges that resulted in only using this method. The majority of the ~1800 lines of code are taken up by software for the accelerometer, which only uses four pins, being 5V, Ground, Clock, and Data. The only thing I used the accelerometer was for a simple car game in which you dodge slower cars while going down a road and controlling its location by tilting the hat from side to side. It included a scoring system, as well. This proved to be fairly entertaining during the ceremony. The last major element I added was a binary clock, which uses the internal clock, as I ran out of pins to be able to use a separate chip. It's accurate enough.
The trickiest thing with the software was figuring out how to interrupt the code so that it would switch between the animations, the game, and the binary clock. Interrupters are apparently pretty finicky and the method that they call have to be incredibly short, so I couldn't simply make it call the next mode. I instead used a numbering system and assigned each mode a number, and the interrupter method simply increments the number from 0 to 2. All the animations and rounds of the game check what the mode is set on before they initiate. so if the mode is changed in the middle of an animation or a game, you have to wait until it finishes before it switches to the next mode. It's not optimal but I've yet to ever need to press the reset button, which was a goal of mine.
The next step was tricky, too. I couldn't decide whether I needed to cut off the fabric on the top of the hat, so that the display would hold well on the cardboard underneath, or if I would leave it uncut. I tried them in this order (fortunately I had several non-nostalgic older siblings), and the second method proved a lot neater. I used double sided foam tape around the edge to hold it down, and although the flexible nature of the display seemed to lift off the hat at some edges, it all looked pretty neat. The only alteration I made to the hat was a zip-tie at the center to hold it down and a small slot that exposes the male connectors on the underside of the hat.
Yes, it was heavy. Having all the parts in the back made everything fairly hidden, seeing as the hat was always tilted back. But this also meant it was really back heavy. Fortunately, the zip tie actually dug into my scalp (yes, fortunately) a little and that kept it from slipping back, especially later in the ceremony when I noticed the elastic was loosening up. Now I'm self conscious about my head.
All in all, it was a spectacularly exciting project. I spent several months working on it, and each step of the way provided interesting challenges. It certainly made me an even bigger fan of Arduinos. One of my favorite things about the hat is that it is still incredibly open to whatever else I would like to do with it, with its accelorometer, button, and potentiometer. But at this point, I can simply leave it running the binary clock on my desk. I look forward to what I can learn from the University of Michigan's College of Engineering and how I can expand from what I've learned with this project.
The sketch can be found here.
I was very satisfied by the setup I had at this point, so I began working on the software. I made several animations by simply creating different for loop layouts, and things like spirals were especially fun to program. All of the software uses an onLED method which simply takes the coordinates of the pixel to be turned on, and the duration of time that the LED is left on. Because of this, that means that all the animations I wrote never turn on more than one LED at a time. This was certainly possible, but I was interested in the consequences and challenges that resulted in only using this method. The majority of the ~1800 lines of code are taken up by software for the accelerometer, which only uses four pins, being 5V, Ground, Clock, and Data. The only thing I used the accelerometer was for a simple car game in which you dodge slower cars while going down a road and controlling its location by tilting the hat from side to side. It included a scoring system, as well. This proved to be fairly entertaining during the ceremony. The last major element I added was a binary clock, which uses the internal clock, as I ran out of pins to be able to use a separate chip. It's accurate enough.
The trickiest thing with the software was figuring out how to interrupt the code so that it would switch between the animations, the game, and the binary clock. Interrupters are apparently pretty finicky and the method that they call have to be incredibly short, so I couldn't simply make it call the next mode. I instead used a numbering system and assigned each mode a number, and the interrupter method simply increments the number from 0 to 2. All the animations and rounds of the game check what the mode is set on before they initiate. so if the mode is changed in the middle of an animation or a game, you have to wait until it finishes before it switches to the next mode. It's not optimal but I've yet to ever need to press the reset button, which was a goal of mine.
The binary clock and racing game
The next step was tricky, too. I couldn't decide whether I needed to cut off the fabric on the top of the hat, so that the display would hold well on the cardboard underneath, or if I would leave it uncut. I tried them in this order (fortunately I had several non-nostalgic older siblings), and the second method proved a lot neater. I used double sided foam tape around the edge to hold it down, and although the flexible nature of the display seemed to lift off the hat at some edges, it all looked pretty neat. The only alteration I made to the hat was a zip-tie at the center to hold it down and a small slot that exposes the male connectors on the underside of the hat.
Everything plugged in (excluding a 4xAAA battery pack)
A better view of the male headers (dem resistors, tho)
The underside of the protoshield
All in all, it was a spectacularly exciting project. I spent several months working on it, and each step of the way provided interesting challenges. It certainly made me an even bigger fan of Arduinos. One of my favorite things about the hat is that it is still incredibly open to whatever else I would like to do with it, with its accelorometer, button, and potentiometer. But at this point, I can simply leave it running the binary clock on my desk. I look forward to what I can learn from the University of Michigan's College of Engineering and how I can expand from what I've learned with this project.
The sketch can be found here.