Using my Arduino, a 7-segment LED, and a shift register

7-segmentI dug out a pile of my old electronic components to see if anything would be useful with my Arduino only to discover that most of the stuff I have just isn’t needed when you are using a microcontroller. I did, however, have a 7-segment LED. At first I plugged it into the outputs on the Arduino, but this used up nearly all of them to run the single 7-segment LED. I did some searching and came across the amazing shift register. I had never used one before, but found this great introduction at bildr, including sample code for controlling eight LEDs. I replaced the LEDs from the example with my LED segments and voila! It worked! I didn’t feel like getting my camera out, so this post has an awful cell phone picture with bad lighting. It is showing a J on my 7-segment LED.

Shift registers are amazing. I used an 8-bit shift register, which let me control 8 pins using only 3 pins on my Arduino. Even cooler, you can daisy chain the shift registers. For example, if I had two 8-bit shift registers then I’d be able to control 16 pins using the same 3 pins on my Arduino. With three 8-bit shift registers I could control 24 pins using only 3 pins, and so on.

These little gizmos cost $1.50 plus shipping at SparkFun, but if you are willing to wait for slow shipping from China then you can get a pack of 20 for only $4.99 with free shipping at AliExpress ($0.25/each). Turns out you can get a lot of the little bits and pieces available at SparkFun (like push buttons, ICs, and LEDs) for significantly less on eBay and AliExpress if you are willing to wait for it to arrive from China or Hong Kong.

Leave a Reply

Your email address will not be published. Required fields are marked *