Wednesday, February 23, 2011

Project 17 - Shift Register 8-Bit Binary Counter

I enjoyed this project... for the first time in a long time, I finally understand how this type of chip works. I've encountered it before in other circuits, but there's never really been a good explanation for how it gets the data in there, holds it, and then knows when to release it.

The author covers quite a bit here, so I read the project text over twice before beginning. I already had a strong understanding of binary, so that part was easy enough to follow, but the explanation of Latch, Data, and Clock pins took an extra read... but it was worth it. Make sure to step through Table 6-4 on page 117 if this confuses you... that table really helped.

Not sure if the binary value the author uses at bottom of page 117 is an error or not, but it only shows 8 bits as 0011011 and the author references a Logic Analyzer figure on page 118 that appears to show the binary value of 00110111 for a total of 8 bits... maybe I'm wrong, but can someone else take a look?

The code is fairly easy to follow, but I had to really pay attention on the bit shifting portion of the code to understand what's going on there. It's an interesting project and the code totally makes sense now.

The video shows what happens when it's plugged in - I didn't record the entire count up from 0 to 255, but it does eventually light up all the LEDs for a value of 255!


  1. I was thinking exactly the same thing about the logic probe read out as I was trying to match it to the value 00110110. I'd just about convinced myself that it was because I didn't know anything about logic probes until I read your post, so I feel better now.

    I also thought this was a cool project. I already understood the idea of binary numbers, but this project made me really sit and think about how each bit represented a power of 2 and how a "bit shift" means raising or lowering a value by a power of 2.

    I finished project 18 a couple of weeks ago, but it has been so thought provoking, that I have left it set up and running in the shop. At first it was just mesmerizing to watch the blinkies, but after a while I found myself quickly able to read the binary numbers and translate them into base ten. ("two to the seventh plus two to the third, that's 136..137..138...")

    From there it occurred to me that a simple binary display would be a great way to demonstrate some basic number theory for my students. Then I decided that instead of simply building a larger version of project 18, I needed to build a clock with 3 binary displays, one each for hours, minutes, and seconds.

    This sent me on a side trip to learn the DS1307 Real Time Clock and how to connect it to the Arduino via I2C. The pipe dream is to have a binary display clock interface with another crazy little micro controller project I've already set up...a toy glockenspeil which uses a servo driven hammer to play the notes. Instead of chiming the hours, it will chime near the end of each class period to cue the kids when it is time to clean up the room before the passing bell rings.

    Anyway, I ordered a bag of big blue LEDs and am working up a stencil design of the clock display that I'll cut from black vinyl on my wife's Cricut machine. This will show the hours, minutes and seconds in powers of 2 and will overlay a sheet of clear acrylic so that each 2^nth will appear black for zero or bright blue for 1.

    I think it will not only make a nifty classroom display, but will also be a useful teaching tool for understanding exponents...especially the pesky idea that n^0=1, which kids always find to be counter intuitive.

    For me, this illustrates one of the great beauties of the Arduino...I have often contemplated the idea of building things like this to quickly, and physically illustrate mathematic or scientific ideas, but have been unable to figure out how to control them, even as I clearly understood the basic programming ideas that would be needed. Arduino allows me to quickly and cheaply build projects that formerly would have been financially prohibitive as well as technically outside my skill set.

  2. The clock project sounds fun and interesting. I'm sure your class will like it.

    I'm going to try and get Project 18 finished today.

  3. can i ask for the code for this?thank you.. :)

  4. All of the code can be downloaded from Search for the title of the book snd the book's webpage has a link to download the code.

  5. i also have done this project, but the last 2 LEDS do not light. it is like it skips from 63 right back to 1. the code is copied right from the book (it is in PDF so i can copy / paste the code).
    i checked and check and check everything. cant figure it out. i was thinking that it was the shift register, but why would it go from 111111 to 000001.