0% found this document useful (0 votes)
10 views9 pages

Lecture Topic 3.2.2 LED Binary Project

Uploaded by

vasuwattsuser
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views9 pages

Lecture Topic 3.2.2 LED Binary Project

Uploaded by

vasuwattsuser
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Project-Creating an LED binary number display using shift register

Seven segmented displays are great. They are pretty simple, don't take much power, and have a lot of
flexibility when it comes to displaying numbers. But setting aside 14 pins just to run it is such a pain. If
only there was a way to use them without sacrificing so many precious pins. Turns out there is! Shift
Registers are logical IC's that can hold or shift data sent into them. They only take up three pins.

Step 1: Components Required


 Arduino Uno
 2 digit 7 segmented display (common anode)
 2x 74HC595 shift register
 14x 660 ohm resistors
 Breadboard
 Jumper wires
 USB cable
Step 2: Circuit
Now this can get a little dense if you're not careful so plan ahead. Not only do you have to keep track
of which led goes where, you also have to keep track of how it interfaces with the shift registers.
We will use two colors for wiring so we knew which digit when where. Don't forget that because this
is a common anode display all of the led's will be on when the IC sinks the current into them
instead of being a source.

Step 3: Shift Registers


But how does this all work? Shift registers have a very specific function. They either store a
digital state or shift that state to the next bit on the next clock cycle. This means that a stream of bits
can be shifted into registers in combination with the clock using just those two inputs. It doesn't
"erase" anything, it just tries to shift it left and out to another register if possible. The third input,
the latch, is used as a read/write safety. Even though the clock tells when to shift, the latch must allow a
shift to happen. If the latch is high, then data cannot be written to the register and the register holds the
data.
Step 4: Arduino Code
The positions of each led need to be translated into numbers. By marking the combinations that result in
numbers and formatting that into binary of hex data, each number can be easily accessed.

This is the code for making the shift registers count from 0 to 99 and loop. Notice how the latch first has
to be set low, then shifted out, then set high again. The latch is what allows the registers to retain their
position in between clock cycles. The second digit comes first because it is sent into register 1 and then
shifted by 1 byte out to register 2 as digit one takes its place.

#define LATCH 4
#define CLK 3
#define DATA 2
//This is the hex value of each number stored in an array by index num
byte digitOne[10]= {0x6F, 0x09, 0x73, 0x3B, 0x1D, 0x3E, 0x7C, 0x0B, 0x7F,
0x1F}; byte digitTwo[10]= {0x7B, 0x11, 0x67, 0x37, 0x1D, 0x3E, 0x7C, 0x13, 0x7F,
0x1F};

int i;
void setup(){
pinMode(LATCH, OUTPUT);
pinMode(CLK, OUTPUT);
pinMode(DATA, OUTPUT);
}
void loop(){
for(int i=0; i<10; i++){ for(int j=0; j<10; j++){
digitalWrite(LATCH, LOW);
shiftOut(DATA, CLK, MSBFIRST, ~digitTwo[i]); // digitTwo
shiftOut(DATA, CLK, MSBFIRST, ~digitOne[j]); // digitOne
digitalWrite(LATCH, HIGH);
delay(500);
}
}
}

You might also like