Seven Segments display and the multiplexing display strategy
If you need additional specific information about this topic or if you want to look it personally please write an email
In order to turn on or off a pin you need simply to put as HIGH the signal for that pin.
As you can also see from the electric schema, this component is nothing more than a group of 7 leds (diode) put together with a common pole, in this case the Anode. In fact, to be more detailed you can have two kind of seven segs digit.
The ones with common cathode and with common Anode .
Now if you have 8 leds (the 8th is the comma) with a common pole (ground for example), how many Arduino PINS will you need to drive just a digit? The answer is very easy: you will need 8 digital pins plus the connection to the ground one.
Imagine now to connect 8 digits to an Arduino board (or any other logic controller. You will need 8*8+1 pins (65). As you can understand this can be very expensive and complex to implement.
With this basic configuration, you can activate and deactivate the signal pin in order to switch on and off the digits in sequence. If you switch them on and off sequentially displaying different numbers on each digit and if the display frequency is higher than 30 MHz then you eyes
will not see the digit switched of but the persistence effect will mask the view and it will seems to you that you are properly display the entire number.
It is time now to give a look at the code needed
int pin1 = 2;
int pin2 = 3;
int pin3 = 4;
int pin4 = 5;
int pin5 = 6;
int pin6 = 7;
int pin7 = 8;
int gnd1 = 11;
int gnd2 = 9;
int timer = 1000;
Now, in the setup function you need to initialise any single digital pin using the pinmode command:
ipinMode(pin1, OUTPUT);
pinMode(pin2, OUTPUT);
pinMode(pin3, OUTPUT);
pinMode(pin4, OUTPUT);
pinMode(pin5, OUTPUT);
pinMode(pin6, OUTPUT);
pinMode(pin7, OUTPUT);
pinMode(gnd1, OUTPUT);
pinMode(gnd2, OUTPUT);
Now, simply switching the two ground pins (setting them true and false in an intervall of 0.5 ms), you will see the refresh effect and your eyes will see a number of 2 digits displayed for 2 seconds (1000 * 0,5)
//this represents the number "20"
for (int i=0; i=timer-1; i++){
digitalWrite(pin1, B1);
digitalWrite(pin2, B1);
digitalWrite(pin3, B0);
digitalWrite(pin4, B1);
digitalWrite(pin5, B0);
digitalWrite(pin6, B1);
digitalWrite(pin7, B1);
digitalWrite(gnd1, B0);
digitalWrite(gnd2, B1);
delay(0.5);
digitalWrite(pin1, B1);
digitalWrite(pin2, B1);
digitalWrite(pin3, B1);
digitalWrite(pin4, B0);
digitalWrite(pin5, B1);
digitalWrite(pin6, B1);
digitalWrite(pin7, B1);
digitalWrite(gnd1, B1);
digitalWrite(gnd2, B0);
delay(0.5);
}
This example is very easy to understand but does nothing more than a display. However, it is very useful in order to understand the concept of multiplexing and how to use same pins to drive different digits. Following this example you can immediately: