Project tutorial
Shift Register Tutorial

Shift Register Tutorial © GPL3+

A guide how to control 7 segment display with Shift register as well as daisy chain them to create multi digit displays

  • 2,741 views
  • 0 comments
  • 4 respects

Components and supplies

Apps and online services

About this project

Some time ago I did tutorial on how to control 7 segment display with Arduino. We were using 7 pins of Arduino to do this.

This tutorial introduces shift registers that allow us to control multiple 7 segment displays with just 3 pins

Please go to:

https://youtu.be/QI1IJLB42G8

If you like this content and you want to support me in clreating similar videos go to my Patreon webpage

https://www.patreon.com/MariosIdeas

Or

https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7PD67JWZ9S3EJ&source=url

Code

Conreol 7 segment display with Arduino and Shift Register to display digit sequence 0-9Arduino
int DS1_pin = 4;
int STCP1_pin =3;
int SHCP1_pin = 2 ;

int digits [10][8]{
  {0,1,1,1,1,1,1,0}, // digit 0
  {0,0,1,1,0,0,0,0}, // digit 1
  {0,1,1,0,1,1,0,1}, // digit 2
  {0,1,1,1,1,0,0,1}, // digit 3
  {0,0,1,1,0,0,1,1}, // digit 4
  {0,1,0,1,1,0,1,1}, // digit 5
  {0,1,0,1,1,1,1,1}, // digit 6
  {0,1,1,1,0,0,0,0}, // digit 7
  {0,1,1,1,1,1,1,1}, // digit 8
  {0,1,1,1,1,0,1,1}  // digit 9
};


void display_digit(int d){
  if (digits[d][0]==1) digitalWrite(7, LOW); else digitalWrite(7, HIGH); //A
  if (digits[d][1]==1) digitalWrite(8, LOW); else digitalWrite(8, HIGH); //B
  if (digits[d][2]==1) digitalWrite(9, LOW); else digitalWrite(9, HIGH); //C
  if (digits[d][3]==1) digitalWrite(2, LOW); else digitalWrite(2, HIGH); //D
  if (digits[d][4]==1) digitalWrite(3, LOW); else digitalWrite(3, HIGH); //E
  if (digits[d][5]==1) digitalWrite(5, LOW); else digitalWrite(5, HIGH); //F
  if (digits[d][6]==1) digitalWrite(4, LOW); else digitalWrite(4, HIGH); //G
}

void DisplayDigit(int Digit)
{
    digitalWrite(STCP1_pin,LOW);
    for (int i = 7; i>=0; i--)
   {
    digitalWrite(SHCP1_pin,LOW);
    if (digits[Digit][i]==1) digitalWrite(DS1_pin, LOW); 
    if (digits[Digit][i]==0) digitalWrite(DS1_pin, HIGH);
    digitalWrite(SHCP1_pin,HIGH);
   }
   digitalWrite(STCP1_pin, HIGH); 
}


void setup() {  
  pinMode(DS1_pin, OUTPUT);
  pinMode(STCP1_pin, OUTPUT);
  pinMode(SHCP1_pin, OUTPUT);
}

void loop() {
for (int i=0;i<10;i++){  
  DisplayDigit(i);  
  delay(300);
}
} 
Control 7 display with Arduino and Shift Register-display digit sequence 0-9 using SHIFTOUT functionArduino
int DS_pin = 4;
int STCP_pin =3;
int SHCP_pin = 2 ;

int dec_digits [10] {1,79,18,6,76,36,32,15,0,4};

void setup() {

  pinMode(DS_pin, OUTPUT);
  pinMode(STCP_pin, OUTPUT);
  pinMode(SHCP_pin, OUTPUT);
}


void loop() { 
 
for (int i=0;i<10;i++){
  digitalWrite(STCP_pin,LOW);
  shiftOut(DS_pin, SHCP_pin, LSBFIRST,dec_digits[i]);
  digitalWrite(STCP_pin, HIGH);
  delay(300);

}
} 
Connect two 7 segment displays to show count from 0 to 99Arduino
Two shift registers are daisy chained . When one is overflown it pushes bits to teh other one
int DS_pin = 4;
int STCP_pin =3;
int SHCP_pin = 2 ;

int dec_digits [10] {1,79,18,6,76,36,32,15,0,4};


void setup() {

  pinMode(DS_pin, OUTPUT);
  pinMode(STCP_pin, OUTPUT);
  pinMode(SHCP_pin, OUTPUT);
}


void loop() { 

  
for (int j=0;j<10;j++){  
for (int i=0;i<10;i++){
  digitalWrite(STCP_pin,LOW);
  shiftOut(DS_pin, SHCP_pin, LSBFIRST,dec_digits[i]);
  shiftOut(DS_pin, SHCP_pin, LSBFIRST,dec_digits[j]);
  digitalWrite(STCP_pin, HIGH);
  delay(300);
}
}
} 

Schematics

7 segment display connected to shift registor and arduino
Diagram oga981tfzj

Comments

Similar projects you might like

4 Wire LCD Control with BL and Contrast Using Shift Register

Project showcase by Mike Kowalski

  • 3,412 views
  • 2 comments
  • 11 respects

Digital Clock with Arduino, RTC and Shift Register 74HC595

Project tutorial by LAGSILVA

  • 38,641 views
  • 30 comments
  • 80 respects

Working with Shift Register

by SBR

  • 5,124 views
  • 2 comments
  • 9 respects

Arduino Fingerprint Sensor Tutorial

Project tutorial by Nick Koumaris

  • 90,351 views
  • 7 comments
  • 118 respects
Add projectSign up / Login