Let’s learn how to configure a SSD (Seven segment display) with Arduino. You will also learn to make the counter using a single SSD.
Contents:
1. Introduction
The Seven Segment Display has basically 10 pins and is of two types: Common anode and common cathode. In common anode, making a pin HIGH means you are switching off that particular. Moreover, common cathode is opposite of this fact. I have common anode(CA) SSD with me and the code is for that. So make sure you check the model of your SSD. You have to change the LOW pins to HIGH in the code and vice versa if you have the CC (Common cathode) SSD with you.
2. Materials Required
- Seven Segment Display (SSD)
- Arduino board (UNO/Nano)
- Jumper wires
- A resistor (1k is sufficient)
3. Circuit
The connection is a bit complex. Refer this pinout of seven segment display.
The com pin present in the SSD is the common pin. It is connected to 5V in case of CA and GND in case of CC. This is checked by looking at the lateral side of SSD. “CA” or “CC” is written there. Now, make the connections as given in the circuit. For circuit improvisation, we have used only 1 resistor apart from using each resistor for each segment.
4. Arduino Code
Refer this arduino code below and upload it to the board. Make sure you select the correct COM port.
int count=0;
void setup() {
int i;
for(i=3;i<=9;i++)
{
pinMode (i,OUTPUT);
}
}
void loop()
{
switch(count)
{
case 0 :
digitalWrite (3,HIGH);
digitalWrite (4,LOW);
digitalWrite (5,LOW);
digitalWrite (6,LOW);
digitalWrite (7,LOW);
digitalWrite (8,LOW);
digitalWrite (9,LOW);
break ;
case 1 :
digitalWrite (3,HIGH);
digitalWrite (4,HIGH);
digitalWrite (5,HIGH);
digitalWrite (6,LOW);
digitalWrite (7,HIGH);
digitalWrite (8,HIGH);
digitalWrite (9,LOW);
break ;
case 2:
digitalWrite (3,LOW);
digitalWrite (4,HIGH);
digitalWrite (5,LOW);
digitalWrite (6,LOW);
digitalWrite (7,LOW);
digitalWrite (8,LOW);
digitalWrite (9,HIGH);
break ;
case 3:
digitalWrite (3,LOW);
digitalWrite (4,HIGH);
digitalWrite (5,LOW);
digitalWrite (6,LOW);
digitalWrite (7,HIGH);
digitalWrite (8,LOW);
digitalWrite (9,LOW);
break ;
case 4 :
digitalWrite (3,LOW);
digitalWrite (4,LOW);
digitalWrite (5,HIGH);
digitalWrite (6,LOW);
digitalWrite (7,HIGH);
digitalWrite (8,HIGH);
digitalWrite (9,LOW);
break ;
case 5 :
digitalWrite (3,LOW);
digitalWrite (4,LOW);
digitalWrite (5,LOW);
digitalWrite (6,HIGH);
digitalWrite (7,HIGH);
digitalWrite (8,LOW);
digitalWrite (9,LOW);
break ;
case 6 :
digitalWrite (3,LOW);
digitalWrite (4,LOW);
digitalWrite (5,LOW);
digitalWrite (6,HIGH);
digitalWrite (7,LOW);
digitalWrite (8,LOW);
digitalWrite (9,LOW);
break ;
case 7:
digitalWrite (3,HIGH);
digitalWrite (4,HIGH);
digitalWrite (5,LOW);
digitalWrite (6,LOW);
digitalWrite (7,HIGH);
digitalWrite (8,HIGH);
digitalWrite (9,LOW);
break ;
case 8:
digitalWrite (3,LOW);
digitalWrite (4,LOW);
digitalWrite (5,LOW);
digitalWrite (6,LOW);
digitalWrite (7,LOW);
digitalWrite (8,LOW);
digitalWrite (9,LOW);
break ;
case 9:
digitalWrite (3,LOW);
digitalWrite (4,LOW);
digitalWrite (5,LOW);
digitalWrite (6,LOW);
digitalWrite (7,HIGH);
digitalWrite (8,LOW);
digitalWrite (9,LOW);
break ;
}
if(count<10)
{ count++;
delay(1000);
}
if(count==10)
{count=0;
delay(1000);}
}
5. Code Explanation
In my arduino code, I have used the switch case with an if-else loop. The counter will start from 0 and will end at 9. After 9 is displayed at the SSD, I have given the command to change it back to 0. In this way the whole code runs.
I hope you were able to integrate the SSD with the Arduino interface. Mention in the comment section if you find any errors. Happy Learning!