# How to use 7 Segment using Shift Register

Controlling one seven segment using shift register or HOW TO USE 7 SEGMENT USING SHIFT REGISTER. Weâ€™ll control the LED display using shift register, by connecting pins A through DP to the shift register outputs Q0 to Q7.

In the previous tutorial working of Shift Register IC 74HC595, includes LSB first and MSB first concept is already discussed. Now, Use the table shown below which helps you to determine which segments to turn ON and OFF to display a particular number or letter.

The first row in the table shows the shift register output pins, which are used to control the segments pins shown on the second row. From the next row it shows the number that can be displayed, with the corresponding binary and decimal values to send to the shift register IC.

### TABLE: DISPLAY SEGMENT MATRIX WITHOUT DP ON

 Â Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7 Â Segment A B C D E F G DP DECIMAL 0 1 1 1 1 1 1 0 0 252 1 0 1 1 0 0 0 0 0 96 2 1 1 0 1 1 0 1 0 218 3 1 1 1 1 0 0 1 0 242 4 0 1 1 0 0 1 1 0 102 5 1 0 1 1 0 1 1 0 182 6 1 0 1 1 1 1 1 0 190 7 1 1 1 0 0 0 0 0 224 8 1 1 1 1 1 1 1 0 254 9 1 1 1 1 0 1 1 0 246 A 1 1 1 0 1 1 1 0 238 B 0 0 1 1 1 1 1 0 62 C 1 0 0 1 1 1 0 0 156 D 0 1 1 1 1 0 1 0 122 E 1 0 0 1 1 1 1 0 158 F 1 0 0 0 1 1 1 0 142

For example, to display the digit 7, we need to turn ON LED segments A, B, and C, which correspond to the shift register outputs Q0, Q1, and Q2.

Therefore, we will send the byte B1110000 into the shift register with shiftOut set to LSBFIRST to turn ON the first three outputs that match the desired LEDs on the module.

Next, weâ€™ll create a circuit that displays, in turn, the digits 0 through 9 and then the letters A through F. The cycle repeats with the decimal-point (DP) LED turned on.

### PROGRAMMING CODE : HOW TO USE 7 SEGMENT USING SHIFT REGISTER

```#define DATA 6 Â Â Â Â Â // connect to pin 14 on the 74HC595
#define LATCH 8 Â Â Â Â // connect to pin 12 on the 74HC595
#define CLOCK 10 Â Â Â // connect to pin 11 on the 74HC595
// setting up a array named data, with the segments for 0 to Â 9, A to F
int data[] = {252, 96, 218, 242, 102, 182, 190, 224, 254, 246, 238, 62, 156, 122, 158, 142};
void setup() {
Â pinMode(LATCH, OUTPUT);
Â pinMode(CLOCK, OUTPUT);
Â pinMode(DATA, OUTPUT);
}
void loop() {
Â int i;
Â // display digits 0-9, A-F without DP
Â for ( i = 0 ; i <= 15 ; i++ ) {
Â Â Â digitalWrite(LATCH, LOW);
Â Â Â shiftOut(DATA, CLOCK, LSBFIRST, data [i]);
Â Â Â digitalWrite(LATCH, HIGH);
Â Â Â delay(250);
Â }
Â // display digits 0-9, A-F with DP
Â for ( i = 0 ; i <= 15 ; i++ ) {
Â Â Â digitalWrite(LATCH, LOW);
Â Â Â shiftOut(DATA, CLOCK, LSBFIRST, data [i] + 1); Â Â // +1 is to turn on the DP led
Â Â Â digitalWrite(LATCH, HIGH);
Â Â Â delay(250);
Â }
}
```

Here, we store the decimal values in the int data [] array. In the void loop,

In 1st for loop, we send these values to the shift register in sequential order and then

In 2nd for loop repeat the process with the decimal point on by adding 1 to the value sent to the shift register.

DISPLAY TWO DIGIT NUMBER ON SEVEN SEGMENT DISPLAY

Subscribe
Notify of