I received the latest Adafruit AdaBox last Thursday and made this unboxing video.
As you may have guessed, AdaBox004 has a music theme. I’m excited because I’ll be using several of these parts in my current project. I need to finish it before the weekend so I guess I better get my ass in gear.
When you lay it out, this one seemed a light compared to the first 3 AdaBoxes, so I added up prices from the Adafruit store. It came to $73 without factoring in the empty white box for making a custom project enclosure, collectible “Boomy” pin, SD card, Make volume 57 signed by LadyAda, and free shipping. Probably about a $90 value for $60 as a subscriber, which is worth it. The $25 Music Maker FeatherWing with the $20 Feather HUZZAH really drove up the price, limiting what else could be included.
If you enjoyed the music in the video, it was released by Adafruit’s in-house musician to go along with this box. Check out “ADABOX004” on SoundCloud. BartleBeats also has a full album I’ve been listening to a lot while working at my hobby desk. “Frequency” is available on SoundCloud or via iTunes.
Next up… this morning I received the tracking info for HackerBox #0020. Note that AdaBox uses a 3 digit identification system, while the HackerBox uses 4 digits. The difference between a quarterly and a monthly subscription I guess.
You can buy all sorts of 5V relay modules on Amazon for as little as $3-4 (probably even less if you get really cheap). They even sell boards with multiple relays if you need to switch more than one thing. Since I had all of the necessary parts I built my own. Yesterday I finished the board, because I had to do something before National Week of Making ended.
It worked great switching power from a 9V battery, but the real test was hooking it up to mains power. Electricity gets a lot more dangerous at 120V! It was a little scary plugging everything in and flipping the input, especially after reading so many warnings online, but there were no sparks.
I need to pick up a plastic outlet box to house everything so it’s safer with the exposed soldered circuit board in there; I don’t know what I was thinking when I bought a metal one. I’ll publish a more detailed post this weekend when it’s complete.
Update: I realized the relay I used in this module can’t handle the amount of current I need, so I ordered a different type of relay and will be making a new module. I’ll take the opportunity to make a more compact design as well. I did shrink this one a bit and cut off some of the board. I’ll save this module in case I ever need it for a project.
I picked up a 10 pack of these 7 segment red LED displays for less than $5. Since each display requires connecting to a minimum of 8 of the 10 pins (9 if using the decimal point), they aren’t exactly easy to work with. Sure, you can buy these where 2 or 4 displays are already connected in a nice package, controlled with the help of an integrated circuit, but where is the fun in that?
If you need to use more than 1 or 2 displays (at 8-9 pins per display), you’ll quickly run out of pins on your microcontroller or Raspberry Pi. The most common way to work with several of these displays is called multiplexing. It’s a method where you briefly turn on one display, turn it off, turn on the next one, and turn it off. You repeat this through all of your displays and then start over. If you do this fast enough, the human eye thinks all of the displays are on at once. It’s pretty slick!
The advantages of multiplexing are:
Fewer wires/pins needed to drive the displays.
Lower power consumption since the LEDs on only one display are lit.
Let’s get our hands dirty, shall we?
Seven of the pins on one of these displays match up to the 7 segments (labeled a through g), one pin is for the decimal point (DP), and the two remaining pins can be used for the common cathode (cc), though you only need to connect one or the other. Over to the right you can see how all of the pins and LED segments are arranged. Pretty straight forward.
I’m using 6 of these displays in a project, so I needed a lot of wires. It got complex and tangled in a hurry, but amazingly, I connected all the wires without a single mistake on my first try. 🙂 For the most part, I based my circuit design off of this schematic…
The end result is something like the Fritzing screenshot below. With so many wires overlapping, it’s not easy to see what’s really going on here. I suggest grabbing wiring.fzz from my GitHub repo and playing around with it in the Fritzing app.
When I went to write my proof of concept code, I decided to use the Gpiozero Python library to simplify working with the LEDs. The library allowed me to set up a couple of arrays for the LED segments and the 6 digits (displays)…
segment_leds = 
for i in range( len( segment_pins ) ) :
segment_leds.append( LED( segment_pins[i] ) )
digits = 
for i in range( len( digit_pins ) ) :
digits.append( LED( digit_pins[i] ) )
Then I could easily loop through and toggle the LEDs in a display as necessary…
for i in range( len( digits ) ) :
for j in range( 7 ) :
if ( numbers[ digit_values[i] ][j] ) :
To make sure things worked I count up from 999000 and then start back at 000000 after hitting 999999. You can see the full code on GitHub.
Now for some visual proof that I actually got it all working! Here it is running when I keep one digit lit for 5/10,000th of a second before turning it off and lighting the next digit.
You’d never know that only one digit is turned on at a time, would you?
If I change from 0.0005 to 0.05 of a second you can start to see that only one display is on at any point in time.
You may also notice it’s counting up a low slower due to the way this code increments the counter. Don’t worry about that.
When I keep each digit turned on for half of a second you can really see how this works.
An issue I’m running into on a Pi Zero is when the processor gets busy doing other tasks, there is a bit of flicker across the displays. You can see this a couple of seconds in to the first video. I’m guessing the code would perform much better on a Raspberry Pi 3B. For my project it’s not a concern, but I want to mention it in case you follow this for your own project. You may also pick up what looks like random flickering of a single digit here and there but that’s due to video timing; the human eye doesn’t see any of that when it’s in front of you.
If necessary, you can take multiplexing a step further and only light up an individual LED on each display at a time, with a method called charlieplexing. It will use even less power, but due to the speed at which you need to switch from one LED to the next, especially across an array of multiple displays, you lose brightness to the human eye.
In parts 1 and 2, I walked through my journey of repurposing the keypad out of a phone from 1980. I learned that a more modern keypad matrix doesn’t exactly function (behind the scenes) in a way I’d expect. I wanted to understand it better so I set out to recreate a 2×2 keypad (kept it simple to make wiring easier) that would function the same way as something you can buy today. It would be a success if it worked with the Arduino Keypad Library.
From my earlier looks through the code I knew it pulsed power out to a column pin and then read in each row’s key from that column before switching to the next column and repeating the process. I figured that should be enough for me to wire this up and try example programs without going back to look at the library’s code again.
I don’t know why I was thinking this would be more complicated and at least a little more exciting, but it was unbelievably easy. I guess I should be celebrating I understood how it worked. Literally all you do is connect one side of every button in a column to a pin and one side of every button in a row to a pin. No need for connections to power, or ground. No pull up/down resistors.
It immediately worked with the Arduino Keypad library examples, even the MultiKey one. I guess being able to detect multiple key presses at once is where the advantage to this implementation comes in. It worked flawlessly when pressing 2 of the 4 buttons, but when you get to 3/4 there are too many connections to distinguish the keys.
Just to be sure I had it figured out, I added a 3rd column to make it a 2×3 grid and it was just as easy.
I love the beauty of how simple this is. I’ve added Fritzing for both of these to my phone-keypad GitHub repo (2×2 & 2×3). If you check this PDF, in the How it Works section it has a really good explanation and shows the row and column connections exactly like I came up with.
Naturally now I need to do a part 4 and attempt to recreate the keypad implementation I ended up with from the old phone. Due to how it mechanically makes the electrical connections I think it’s going to be a bit more complicated than this was. We shall see…
Electronics Engineering ToolKit is a useful iOS app if you’re messing around with electronics. I think I paid $6.99 to upgrade to Pro, which unlocks all of the formulas, reference material, and tools.
I recently posted Using a 555 Integrated Circuit. There are many ways to use these 555s. To get a sense of the power of this app, it has 10 tools in its 555 Timer IC group! Here’s a look at the Monostable operation mode. Each tool in the app has a great info panel like this one, describing what it does.
The tool itself gives 2 inputs where you set your resistor and capacitor values and it calculates the time for you.
It provides a circuit schematic where the R (resistor) & C (capacitor) values are updated instantly, based on you input values. This schematic doubles as a simulation, where it really gets cool. You can tap on the button to see how the circuit reacts. In this case, the LED turns green (ON) for 2.42 seconds and then turns off.
I wired up the circuit to try it for myself. Worked exactly as expected. I even triggered my live circuit and the simulation at the same time and the LEDs turned off simultaneously.
This is just one example of many useful things you can do in the Electronics Engineering ToolKit app, especially with the Pro upgrade. Not only can you favorite (as shown at the beginning of this post) the tools you find most useful, but the app also has a great search feature.
You can find similar tools for specific formulas and uses around the Internet, but I haven’t come across anything where it’s all in one place with an easy to use interface like this. Perhaps the best web site I’ve found is Basic Electronics Tutorials and Revision, which is a bit higher level in the way their descriptions.