What are multiplexed displays and use of multiplexing

How to display a four number digit in 4 digit 7 segment multiplexed display using Arduino


Category: Arduino Tags: C Programming, Seven Segment

Code files of 4 digit multiplexed display with Arduino

    Multiplexed displays are basically multiple displays which are multiplexed together and usually one is turned on at a time, the turning on and off of multiple displays are so fast that viewer is able to believe that all the displays are turned on at a time.

Multiplexing of displays have some benefits like reduced number of input pins, reduced complexity and less power is required for the display. In this article we will use 4 digit 7 segment multiplexed display and understand how to drive the display using Arduino.

4 digit 7 segment display
Fig 1: 4 digit 7 segment display

 

In above picture we can see total 12 pins. 4 pins for turning on individual digit and 8 pins for segment A-G and DP. Let's look into diagram below how the led's are multiplexed inside this display.

4 digit 7 segment display multiplexed
Fig 2: 4 digit 7 segment display multiplexed

 

In Fig 2 we have a common anode display since all the positives of segments (A-G and DP) are connected to a single pin. Also we have segment pins of a digit are connected with segment pins of other digits, so we have common pins for segments across digits and this is called a multiplexed display. We have 4 columns for each individual digit and 8 rows for 7 segments and for a decimal point. Whenever we want to display a number can be driven from 8 rows and on whichever digit it has to be displayed can be driven by 4 columns.

Now problem is if we want to display 1111 it is easy as we can give output high to D1, D2, D3, D4 (4 columns to turn on all 4  digits) and low to b, c (segment b and c is to drive number 1 on a seven segment).  But in case if want to display 1234 we can not do it simply, if we drive 1 using segments then all the digits will display 1 since there is no separate segment pins for each individual digit.

Solution to this problem is making use of multiplexing, first turn ON D1 and turn OFF all other digits and display 1, then turn ON D2 and turn OFF all other digits and display 2, same goes for D3 and D4 and we start this over. When interval between turning ON and turning OFF is few milliseconds a human eye will not be able to see any blinking and viewer will feel all the digits are ON at a time.

Implementation

 

4 digit 7 segment multiplexed display working with Arduino
Fig 3: 4 digit 7 segment multiplexed display working with Arduino

 

To understand use of multiplexing we build circuit shown in above picture. We use Arduino pins 0-3 for Display D1-D4 and place 220 ohms register in between and 7 pins of Arduino from 5-11 are used to connect 7 segment pins of display. We have connected a potentiometer with 5V and GND and taking input from potentiometer in analog pin A5.

Now we can upload below program to Arduino.

int segmentPins[7] = {5, 7, 9, 10, 11, 6, 8};
int digitPins[4] = {0, 1, 2, 3};
int maxOutput = 1024;
int speedPin = A5;

int numbers[][10] = {
  {0,0,0,0,0,0,1},
  {1,0,0,1,1,1,1},
  {0,0,1,0,0,1,0},
  {0,0,0,0,1,1,0},
  {1,0,0,1,1,0,0}
  };

void setup() {
  //Set mode as output for 7 segments
  for(int i=0; i<7; i++)
    pinMode(segmentPins[i], OUTPUT);
  //Set mode as output for 4 digits
  for(int i=0; i<4; i++)
    pinMode(digitPins[i], OUTPUT);

  //Set mode as input for potentiometer
  pinMode(speedPin, INPUT);
}

void loop() {
  //Printing number 1234
  for(int i=1; i<=4; i++)
  {
    DisplayNumber(numbers[i]);
    TurnOnDigitPin(i-1);
    //Delay = max output of potentiometer - current output of potentiometer
    delay(maxOutput - analogRead(speedPin));
  }
}

void TurnOnDigitPin(int digitPin){
  //Loop through digitPins, turn on only one at a time
  for(int i=0; i<4; i++){
    if(i == digitPin)
      digitalWrite(digitPins[i], HIGH);
    else
      digitalWrite(digitPins[i], LOW);
  }
}


void DisplayNumber(int pattern[]){
    for(int i=0; i<7; i++)
      digitalWrite(segmentPins[i], pattern[i]);
}

Program is self explanatory by help of comments, basically the program is written to display 1234 by displaying 1 in D1, 2 in D2, 3 in D3 and 4 in D4. A delay is introduce between turning ON and OFF leds and the delay time is driven from potentiometer.

When we connect battery to arduino, display starts displaying 1, 2, 3, 4 in D1, D2, D3, D4 respectively with approx 1 second of delay. when we increase speed using potentiometer digits starts switching fast and when potentiometer is on its full output we will be unable to see switching and we will see all the digits are turned On at a same time displaying 1234. To see output of this circuit please watch full tutorial video here:

 


Like 0 People
Last modified on 6 August 2020
Nikhil Joshi

Nikhil Joshi
Ceo & Founder at Dotnetlovers
Atricles: 139
Questions: 12
Given Best Solutions: 12 *

Comments:

No Comments Yet

You are not loggedin, please login or signup to add comments:

Existing User

Login via:

New User



x