I stumbled upon a video made by Andrew Oakley of an inexpensive LED matrix that he'd made using a Raspberry Pi. I thought it was pretty cool and decided I'd like to make something like that myself. I have pretty much followed the essence of his build as described here. So there probably isn't too much point in me going over everything in great detail. The main difference between his project and mine is that I'm using a Raspberry Pi Zero and I've gone for an extra strip of LEDs, making a total of 150 rather than his 96. I wanted it to be a little higher res as our front window is almost directly on the front street and felt that the picture quality might suffer from such close range.
The first thing to do was to follow this tutorial on setting up the Raspberry Pi Zero to operate a neopixel string of LEDs.
Hook up the level shifter and Pi through the breadboard.
Then turn everything on and see if you get the strandtest example to work. I did have a bit of trouble at first, only one LED in the strip was changing colours. After a bit of head scratching I eventually found that it was because of this line in the example.
LED_DMA = 10
I changed it to 5, like it is in the tutorial, and then I had them all.
You can see in the image above that the three sets of LED strips are connected to the power supply individually. My first attempt I wired the three sets together in series but I noticed that the last strip wasn't getting full power, so be sure to wire them to the power supply positive and negative rails in parallel. The data wires, the green one, can be connected using the supplied connectors. Although when I came to put the matrix together I cut those off and just soldered the wires together.
I don't own a staple gun like Andrew used so I had to think about how I could attach the LEDs to the wooden batons without one. The solution that I chose was to drill holes the size of the LEDs and push them through, I could then glue them in place. A bit more work involved but it seemed like the best approach.
Once all the LEDs are glued onto the batons it's a case of attaching all the batons together.
Again without a staple gun I went with the trusty hot glue gun, so gluing the fabric strips onto the batons.
Then hooking up the data wires and connecting the positive and negative rails.
At the end of the run, just cut off the excess wires and wrap them up with a bit of insulating tape.
My main problem with the matrix as it is, was that it has a very limited usage range. Christmas and Halloween are the obvious choices and then maybe a birthday or two, but after that, what are you going to do with it? It was a side thought until my wife, in passing, commented that it could be used for disco nights. With two young children, 6 and 3, we sometimes have the occasion of turning off the lights, getting torches and jumping around the living room while dancing to music. If you have kids you have most probably experienced this wonder of the modern age. So that was it, it had to be a disco thing, but it couldn't just scroll an image, it needed to be something a bit more.
So that was where the two mode matrix came into being. Mode one, it would scroll an image, while mode two it would randomly flash some lights in an amazing 80s light show. I needed this to be super simple to use though. My wife, although being very technically minded, didn't really want to mess about SSHing into a Raspberry Pi of an evening and setting up which python scripts to run. It just needed to turn on and run, so I decided to add a button.
There are tonnes of examples of adding a button to a Pi I picked this one, simply because it was the first one returned by the google search. In my rush to add the button I hadn't thought about how I was going to attach it to the lid of the box. My idea was to make a small hole in the lid and slot the button into it, but as I'd now attached it to the Pi I couldn't do this :(
So I had to cut the wires and re-solder them back on once I'd attached the button to the lid. I'd recommend attaching the wires to the button then the button to the lid and then soldering the button to the Pi :)
Before I sealed the Pi in the box, I connected it to a display and setup the wifi on it and enabled the SSH, this can be done in headless mode but I just thought that would be easier.
That's it for the hardware, you now have an LED matrix that can be rolled up and transported about quite easily.
Most of the script for displaying the picture animation is the same as what Andrew did. I wanted two extra display possibilities though. I wanted to be able to repeat animations and ping pong them. So I added a new command and an extra parameter. Also as I want to be able to just turn it on without too much messing about with scripts and things I added a new text file called imagelist which is a list of images that will be stored on the Pi. When you want to make one active just add the # symbol in front and the script will attempt to find a png and txt file of that name. It just means that I could have Christmas, Halloween, birthday1, birthday2, etc in one file and then it's just a case of changing a hash symbol for which one I actually want displayed.
Getting it to run is quite straight forward, I just followed this tutorial on getting SSH on my phone so that it could talk to the Pi over the wifi. Then for sending the files it's just a case of SFTP, some examples of that are here. I used AndFTP which worked pretty well, allowing me to send the pictures and code without a physical connection, to the device. I created a directory called ledmatrix where I put the images, text files and scripts. You could split them up into further directories if you wanted though.
Finally we just need it to run something when the Pi starts up. So add these two lines to the end of /etc/rc.local but before the exit 0, see here for more info on that if you want it.
python /home/pi/ledmatrix/picanim.py & python /home/pi/ledmatrix/disco.py &
Now when you turn on the Pi both scripts will be run but depending on which way the switch is switched one of them will exit.
Time to turn out the lights and fire up the disco mode and get down with some funky beats.
I thought it would be really cool to attach a microphone to the Pi and have it monitor the sounds to react to the music in some spectrum analyser type way, like this only without the music being routed through the Pi. I couldn't figure out how to do that though, too far out from my knowledge base.
Rewrite the whole thing in C. I still might do this. Running through python is not bad but doing it in C would be so much faster. Not written any C programs for the Pi yet so that might be a fun thing to try.