As you may or may not know, I write a monthly Cool Beans Column for Practical Electronics (PE), which is the UK’s premier electronics, computing, and hobbyist magazine.
A few weeks ago, I received an email from PE reader Simon Moore, who is himself based in the UK. Simon’s message was as follows:
Hi Max, I went through some old copies of PE (or EPE as was) to find your writings on using an MSGEQ7. I’d like to make something similar to your BADASS Display as a project. Before I start, and before I have my brain pickled, can I ask you a few questions to see if I’m on the right track? From your articles, my understanding is that the data from the MSGEQ7 is clocked by an Arduino and the amplitudes of the seven frequency groups are stored in an array. If I’m correct so far, my real question is how do I then render this as a display? Would I update the display at a given frequency (timer interrupt perhaps?) or simply wait until the array is ‘filled’ and then jump to a display routine? Thanks in advance for your help and advice.
Interestingly enough, although the display is physically large and offers a bunch of different effects, I’d forgotten how concise and compact I’d managed to compress the code. Simon agreed, because he immediately responded as follows:
This is just what I wanted to see. In my nightmare-ish imaginings, this was going to be the code equivalent of Tolstoy’s “War and Peace.” It’s a relief to see it is far more compact.
A few days later, another email dropped on the metaphorical floor of my Inbox from a Happy Simon, which is, of course, the best sort of Simon to have. In this new missive, Simon spake as follows:
Well that’s made my day! I’m chuffed! I’ve been experimenting with code lighting up a series of LEDs in response to an analogue input via potentiometer. It’s a small start, but it’s great to get inspired and get the noggin joggin.
Ha! “Get the noggin joggin.” I’ll be using that myself in the not-so-distant future. This communiqué was accompanied by an image of a piece of stripboard and a row of LEDs. Just seeing these LEDs lit up brought a little tear to my eye. In a follow-up message, Simon noted:
Incidentally, and very fortunately, I have a single 24-element NeoPixel ring in my parts-box. I plan to move a stage further by lighting the NeoPixels in response to the potentiometer until I manage to get my hands on some MSGEQ7s.
Oooh, now we are really starting to hum along. However, remembering my first fraught experiences with NeoPixels, I emailed Simon to caution him regarding the fact that these little scamps are particularly prone to failure due to electrostatic discharge (ESD). Simon responded as follows:
Thanks for your advice on NeoPixels and ESD. I did not know! My blood ran cold recalling the cavalier manner in which I’ve handled them in the past. Much to my relief, the NeoPixel ring I have seems to have survived. I’ve been able to incorporate it into an Arduino sketch, and I now have a multi-coloured response to the potentiometer input. I’m using part of the colour code array from your program to achieve this, and boy those NeoPixels are bright. Also, I’ve placed an order for some MSGEQ7s, although I’ll have to wait for delivery from China as the UK prices on eBay were eye-watering.
Following this communication, all went quite for a while. And then, earlier this week, just as I was about to email Simon to see how he was faring, the following message arrived:
My BADASS Display has fallen at the first hurdle. I simply cannot get the MSGEQ7 to output any meaningful data. I am using part of your code to read the analog input of the Arduino and write those to an array, then printing the values to the serial monitor. I’ve tried seven different MEGEQ7s and the output varies from all mid-value to all zeros. Is the chip notoriously unreliable or have I made a mistake somewhere? I’ve attached a photo of the breadboarded circuit in case there is a glaring error that you can see. Any thoughts or ideas would be appreciated before I consign either the chips or myself to the bin.
Oh, the joy of trying to work out what’s going on with someone else’s breadboard (it’s hard enough to determine the state of play with your own breadboard projects). Before you read on, you might want to take a look at the image above yourself to see if anything leaps out at you.
One question that did pop into my mind caused me to inquire why we have both black and blue flying wires connected to the breadboard’s 0V rail. But the thing that really called out to me was the fact that the right-hand side of the 22kΩ resistor isn’t connected to anything. “Hmmm,” I thought to myself (it sounded like a deep James Earl Jones “Hmmm” in my head). So, I posed this question to Simon, who responded as follows:
I feel very chastened for having a blue wire attached to the ground. That is a result of the lazy-itis from which I’ve suffered since birth. It was connected to the audio output ground (now changed to a black wire). The brown wire – which provides the audio source — should be connected to the right-hand side of the 22kΩ resistor (the other side of the resistor is connected to the 0.1uf cap, which is connected to pin 5 of the MSGEQ7). Anyway, I now have an MSGEQ7 that works! But that is just one out of seven. I know that these are CMOS devices, but they arrived in plastic bags and bubble-wrap. Whilst that may have made me a little cavalier in my handling of the chips (I didn’t take any ESD precautions), I can’t help but wonder if this ‘new old stock’ from China were perhaps already damaged or even reject stock. Could I beg your best guess on that? Feel free to say, “Always take ESD precautions, you fool!” It will, in that case, be a lesson learned.
Well, first I informed Simon how delighted I was that he was finally up-and-running. Next, I referred him to the advice in a “Word to the Wise” sidebar I’d included in a recent Cool Beans Column in the bottom right-hand-corner of page 65 in the March issue of PE. As part of this I’d noted: “It doesn’t matter how clever you think you are or how simple is the circuit that you are building, your life will be a lot less frustrating if you do the following: (a) draw your circuit diagram on a piece of paper and (b) compare your physical circuit to the circuit diagram and mark the wires off one-by-one.”
The reason I’d written this in the first place is that I’d omitted a tiny jumper from my own breadboard project and tracking this problem down had taken an inordinate amount of time. I also mentioned that I’ve never had any problems with MSGEQ7s myself. I noted that I wasn’t saying Simon hadn’t received a bad batch, but that I wouldn’t rule ESD out, and I also advised hm to read my Hair-Curling, Tear-Inducing Electrostatic discharge (ESD) column. I concluded by saying that, these days, I always use an ESD mat and an ESD wrist strap whilst working on my hobby projects.
Last but not least, I asked Simon if he minded my using his name, story, words, and photographs as part of this column, employing them as an example of why it’s a good idea to check off the circuit and also to use ESD protection. Simon replied as follows:
Infamy, infamy, they’ve all got it in for me. Yes of course. Let this be a stern warning to all novice tinkerers the world over. I’m currently searching for an antistatic mat on eBay and looking very sheepish.
That sheepish look is one I know well because I’ve so often seen it plastered on my own face. This reminds me of the saying that goes something like: “Experience is what stops you from making mistakes, but making mistakes is how you gain experience.” How about you? Do you have any tips and tricks you’d care to share with the rest of us, so we can gain from your experience and learn from your mistakes?