Earlier this month, I received an email from one David R. Humrich, who hails from Perth, Australia. David informed me that he’d just finished reading the first of my articles in a series on controlling LEDs in the March 2020 issue of Practical Electronics (PE), which is — as you are doubtless aware — the UK’s premier electronics, computing, and maker hobbyist magazine. As part of this Flashing LEDs and Drooling Engineers series, I’m providing downloadable source code for small test programs, and I also include a page of Cunning Coding Tips and Tricks with each article.
David went on to say that he loves lighting effects, and that his younger sister’s pram was the first in their street to be equipped with a headlight and taillight in 1955. He continued as follows:
In the 1960s, as a techie, I was red hot at programming maintenance routines in machine language for PDP-10 and early Burroughs mainframes. But C/C++ is not intuitive for this ageing brain, so your articles are interesting and have got me off my bum and into the vast pile of Arduino stuff I’ve collected over the years. I’m not as scared as I used to be. Based on your articles, I’m now looking forward to playing with “pulsing” and “breathing” LED displays. Anyway, thanks from sunny Perth in Western Australia, I wanted you to know that a whole new world is opening for me, and it’s all your fault…
Since that original contact, we’ve been bouncing emails back and forth about a variety of LED-related topics. And then, yesterday, David, emailed me to say, “Have you come across the Duinotech 8 x 5 RGB Array Shield for Arduino? It looks like fun. They were on a special deal at a local shop today.”
I must admit that this does look temptingly tasty. I replied saying that I haven’t had the opportunity to play with this particular shield, but that I’m sure he will have a lot of fun with it. I also offered a couple of suggestions. The first was that he could implement a simple “worm” program. I just took this video of such a program running on an 8×8 array here in my office.
In this case, my worm’s 1-pixel head is one color, while its 3-pixel body is another. You start by drawing the worm somewhere on the display. Next, the program picks a random direction. One way to think of this is to make a 4-way selection between north, south, east, and west, and then add a check to make sure that the worm isn’t trying to make a 180° turn and “eat itself.” Alternatively, you can make it a 3-way selection between left, right, and forward.
You also have to pick an integer pixel distance to travel between some minimum value (say 1) and some maximum value (say the horizontal or vertical pixel dimension of the array). Then you make the worm move in that direction, one pixel at a time, until you’ve covered the required distance, at which point you generate new random selections and… you get the idea.
Of course, you also have to decide what you are going to do when the worm reaches a “wall” (the side of the array). In my case, the worm simply changes direction (maybe I should have added a pulse of color on its “head” along with a short pause to imply that it was thinking about its next move). An alternative would be for the northern and southern edges of the array to wrap around to each other; similarly, for the eastern and western edges.
You also have to decide how to handle the case where your worm tries to cross itself; that is, its head tries to cross its trailing tail (this isn’t a problem if you have only a 3-pixel tail, which — now I come to think about it — is why my worm has only a 3-pixel tail).
Also, in my case, I decided that my worm would move only in an orthogonal (north, south, east, west) manner, but there’s nothing to say that it shouldn’t have the ability to travel diagonally at 45° angles.
I also suggested to David that something else he might consider would be to use a cheap-and-cheerful MEMS microphone breakout board (BOB) and a tiny MSGEQ7 audio spectrum analyzer BOB along with his 8 x 5 RGB array to create a little audio spectrum analyzer that he could sit next to an audio source like a radio and it would respond to any music, and I pointed him at this article that contains links to a bunch of columns I’ve written about this.
But then I started thinking. It isn’t fair that David should have a new array to play with when I am a man without an array. So, I had a quick Google while no one was looking and ran across this 32 x 32 array from Adafruit. If you get a moment, you really should take the time to visit the Adafruit website because you’ll see the display performing an interesting animation. Whatever array I end up with, I’d like to try emulating this effect.
On the one hand, I really like this display. On the other hand, it’s only about 6″ square and it requires a lot of pins to drive it (I’m guessing it’s multiplexed). I think I’ve been spoiled by NeoPixels, where you could drive the same number of pixels using a single pin.
And then I started thinking about a ping pong ball-based display — the sort of thing I talked about in my Mega-Cool Ping-Pong-Ball–Based LED Displays and YAAPPBBD (Yet Another Awesome Ping-Pong-Ball–Based Display) columns.
In the fullness of time, I would like to create a really humongous version of this type of display. For the moment, however, I’m thinking of a more modest 12 x 12 = 144 pixel display, which will end up being about 20 inches (500 mm) square. This will be large enough to let me do some interesting things, including allowing me to play with a bigger worm (and that’s not something you expect to hear yourself saying very often).
I just ordered 288 ping pong balls ($11 for a pack of 144 on Amazon) and five meters of 30 pixels per meter NeoPixel strips from Adafruit. While I’m waiting for them to arrive, I’m pondering whether to present the ping pong balls in a regular orthogonal array as in the “YAAPPBBD” column, or in the form of a hexagonal matrix as seen in the “Mega-Cool” column.
As I emailed to David, “You can watch for what comes out of this in a future column (either June or July in PE), but however it turns out, this one is all your fault (LOL).”
I will, of course, also be writing about this here on the Cool Beans Blog. In the meantime, as always, I welcome your comments, questions, and suggestions.