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.

Use the table shown 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 that controls 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.

In the next example, 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 LED turned on.

CIRCUIT DIAGRAM

HOW TO USE 7 SEGMENT USING SHIFT REGISTER
Seven Segment Shift Register 74HC595

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.

ALSO READ: DISPLAY TWO DIGIT NUMBER ON SEVEN SEGMENT DISPLAY

Leave a Reply

avatar
  Subscribe  
Notify of

Arduino Tutorials with Basic Electronics: CONTENT

Translate »