arduino 4 digit 7 segment interfacing with shift registersArduino Interfacing with 4 digit non multiplexed 7 segment display using shift registers 74hc595 or CD4094

Welcome in another Arduino tutorial. Today we are going to explain how to interface 4 digit 7 segment display using shift register 4094. We used CD4094 shift register for interfacing but the technique is same and you can choose any other shift register of your choice like 74HC595 etc as well. Also the code written for this purpose is also applicable to interface as many digits as you like without any big change in the code. All you have to do is to increase the pair of 7 segment and shift register.

The reason for choosing this technique for displaying the numeric data over 7 segment is because we will be able to interface big 7 segments with Arduino without having to worry about the code copmlexity. Also this code is non blocking due to non multiplexed nature of the 7 segment.

Although we preferred not to add any resister or any buffer while interfacing 7 segment with shift register but you may need to add few current limiting resisters and/or some buffer to handle the current requirements of the 7 segment. The most common buffer which is used with the shift register is the ULN2003. This is the reason that we chooses common cathode display for this simulation. So if you choose to add ULN between the shift register and the 7 segment display, you may need to choose common anode display instead of common cathode.

Simulation for 4 digit 7 segment shift register in Proteus

Lets first create a simulation file to test our code in the Proteus. We selected the Proteus for this purpose due to its real time simulation nature and the ability to simulate Arduino code pretty well. Most of the time when simulations are running in the Proteus, it means there are highly chances the code will be working in the real time as well. So here is the diagram and the simulation file as well as the running output of the simulation.

Arduino 4 digit 7 segment display using shift register 4094 Prot
Arduino 4 digit 7 segment interfacing using Shift Register 4094 Proteus simulatino

Non multiplexed 7 segment interfacing with Arduino code

Now we come to the point where we have to write the actual code for interfacing the 4 digit 7 segment with Arduino using shift registers. At the time of writing the code we need to make sure how many digits we want to interface? Most of the time you need to write portable code which could be adopted later for further use. So we are going to add a macro which will tell the code how many digits are attached with the shift registers.

#define NUM_OF_DISPLAY 4

Here is a complete code

/*
This test will check if the seven segment 
attached with shift register and ULN2003 are working

*/


#define NUM_OF_DISPLAY 4

//Pin connected to Strobe (pin 1) of 4094
int strobePin = A2; ////atmega(pin-25)
//Pin connected to Data (pin 2) of 4094
int dataPin = A1;  //atmega(pin-24)
//Pin connected to Clock (pin 3) of 4094
int clockPin = A0;  //atmega(pin-23)
char shiftOutBuffer[NUM_OF_DISPLAY]={0};
byte segChar[]={

  0b00111111,
  0b00000110,
  0b01011011,
  0b01001111,
  0b01100110,
  0b01101101,
  0b01111101,
  0b00000111,
  0b01111111,
  0b01101111,
  0b00000000,
  



};

void update_display()
{
  int i=0;      
  digitalWrite(strobePin, LOW);
  for(i=NUM_OF_DISPLAY-1;i>-1;i--)
    {     
      shiftOut(dataPin, clockPin, MSBFIRST, segChar[shiftOutBuffer[i]]);             
    }
  digitalWrite(strobePin, HIGH);      
}


void reset_digits(){
  int i=0;
  for(i=0;i<NUM_OF_DISPLAY;i++)
  {
   shiftOutBuffer[i]=0; 
    
  }
  update_display();

  
}


void setup() {
  int i=0;
  pinMode(strobePin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  for(i=0;i<NUM_OF_DISPLAY;i++)
  {
   shiftOutBuffer[i]=i+1; 
    
  }
  update_display();
  
}

void loop() {
  

}Code language: PHP (php)

By Abdul Rehman

My name is Abdul Rehman and I love to do Reasearch in Embedded Systems, Artificial Intelligence, Computer Vision and Engineering related fields. With 10+ years of experience in Research and Development field in Embedded systems I touched lot of technologies including Web development, and Mobile Application development. Now with the help of Social Presence, I like to share my knowledge and to document everything I learned and still learning.

One thought on “Arduino 4 digit 7 segment Non Multiplexed Display using Shift Register”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.