Wednesday, May 05, 2010

Day +1400 : A binary counter

I am fine today.

Further to my initial project - LED chaser - on the open source Arduino platform, I tried another project which interface the Arduino board with 74HC595 shift register. This project is actually a tutorial on the official Arduino website http://www.arduino.cc/en/Tutorial/ShiftOut.

The shift register gives 8 outputs which each of them driving a LED, thus controlling a total of 8 LEDs. But the good thing is that it needs 3 inputs only; namely data input, clock, and latch. This means that we manage to drive 8 LEDs with 3 output pins from Arduino board.

The 74HC595 shift register pin layout (click to get a larger view) - taken from Arduino website

You might wonder how a single data input on the shift register can drive 8 LEDs. The answer is that the data is input to the shift register one by one with the help of the clock, and once everything (8 bits) is in the shift registers, we just turn on the latch to output the data in the shift register to the 8 pins all at once - a process called serial in parallel out.

Another good thing about the shift register is that it also provides a serial out pin. This allows us to connect a second shift register to the first one, and driving another 8 LEDs. The output of the second shift register and be connected to the third register, and so on to drives more LEDs.

Since Arduino board provides 14 digital output pins only, we can control 14 LEDs only if we connect its pins directly to the LEDs. The introduction of shift registers allows us to drive many LEDs with three Arduino output pins only :-)

After connecting out the system, we have to compile and upload the counting program to the Arduino board. It will then perform the counting. The program is also available at the Arduino website.

I record the operation of the counter for you. The binary counter works as follow:

0 - 00000000
1 - 00000001
2 - 00000010
3 - 00000011
4 - 00000100
5 - 00000101
6 - 00000110
7 - 00000111
8 - 00001000
9 - 00001001, and so on until 255, and then it start from 0 again

Count with 500ms (millisecond) interval, that means two counts every second


10 counts every second, or at 100ms interval


See you next post :-)

No comments: