Skip to main content

How to Interface a 7-Segment Display with an Arduino?


What is Seven-Segment Display?



Seven-Segment Displays are used to display the information; these are widely used in industries due to their visibility and life.

There are two types of seven-segment displays: common anode and common cathode. The Internal structure of each of these types almost same. But, the polarity of the LEDs and common terminal are different.

In most standard cathode seven-segment, all seven LEDs, with a dot LED, have the cathodes connected to the pins 3 and pin 8. To use it, we must connect GND to the pin 3 and pin 8, then connect +5V to the other pins and make each of the individual segments glow. The diagram below shows the internal structure of the common cathode seven-segment display:




While, the common anode display is opposite in respect of common connection. In a common anode display, the Anode of the eight-shaped LEDs are connected together. They are then connected to pin 3 and pin 8. To glow an individual segment (LED), respective pin is to be grounded. The diagram below shows the internal structure of the common anode seven-segment display. 



The dot is labelled as “dp”, while the seven segments are labelled as a, b, c, d, e, f, g, as shown in the figure below:

 


 

 

 

Experiment:

In this experiment, we will learn how to connect a seven-segment display (CC type) to an Arduino Uno.

 

Hardware Required

1 x 7-segment Display Common Cathode Type

7 x 330 ohm resistor

1 x Arduino UNO

1 x USB Cable

1 x breadboard

8 x jumper wires

You turn on the individual segments to display a particular number, as seen in the following.

If you want to glow number 1, then you need to power up segment ‘b’ and ‘c’.

For number two, glow the segments; a, b, g, e, d.

For number three, glow the segments; a, b, g, c, d.

For number four, glow the segments; f, g, b, c.

For number five, glow the segments; a, f, g, c, d

For number six, glow the segments; f, g, e, d, c.

For number seven, glow the segments; a, b, c.

For number eight, glow the segments; a, b, c, d, e, f, g.

For number nine, glow the segments; a, b, c, d, f, g.

For number point, glow the segment dp.

 

So, that is about seven segment display, now we will see how we connect SSD to the Arduino.

Make the connection between SSD and Arduino as shown in the below picture.

Connect the pins, a, b, c, d, e, f, g to the Arduino Pin numbers 8, 7, 6, 5, 4, 3, 2 respectively through resistors 330 ohm.

Connection common of SSD to the GND pin of Arduino

 


 Make the connections as shown in the above picture.

Arduino Code:

#define SSD_a 8 // segment a

#define SSD_b 7 // segment b

#define SSD_c 6 // segment c

#define SSD_d 5 // segment d

#define SSD_e 4 // segment e

#define SSD_f 3 // segment f

#define SSD_g 2 // segment g

 

void setup()

{

pinMode (SSD_a, OUTPUT);

pinMode (SSD_b, OUTPUT);

pinMode (SSD_c, OUTPUT);

pinMode (SSD_d, OUTPUT);

pinMode (SSD_e, OUTPUT);

pinMode (SSD_f, OUTPUT);

pinMode (SSD_g, OUTPUT);

 

digitalWrite (SSD_a,LOW);

digitalWrite (SSD_b,LOW);

digitalWrite (SSD_c,LOW);

digitalWrite (SSD_d,LOW);

digitalWrite (SSD_e,LOW);

digitalWrite (SSD_f,LOW);

digitalWrite (SSD_g,LOW);

}

 

void loop()

{

SSD_0();

delay(1000);

SSD_1();

delay(1000);

SSD_2();

delay(1000);

SSD_3();

delay(1000);

SSD_4();

delay(1000);

SSD_5();

delay(1000);

SSD_6();

delay(1000);

SSD_7();

delay(1000);

SSD_8();

delay(1000);

SSD_9();

delay(1000);

}

 

void SSD_0()

{

digitalWrite (SSD_a, HIGH);

digitalWrite (SSD_b, HIGH);

digitalWrite (SSD_c, HIGH);

digitalWrite (SSD_d, HIGH);

digitalWrite (SSD_e, HIGH);

digitalWrite (SSD_f, HIGH);

digitalWrite (SSD_g, LOW);

}

 

void SSD_1()

{

digitalWrite (SSD_a, LOW);

digitalWrite (SSD_b, HIGH);

digitalWrite (SSD_c, HIGH);

digitalWrite (SSD_d, LOW);

digitalWrite (SSD_e, LOW);

digitalWrite (SSD_f, LOW);

digitalWrite (SSD_g, LOW);

}

 

void SSD_2()

{

digitalWrite (SSD_a, HIGH);

digitalWrite (SSD_b, HIGH);

digitalWrite (SSD_c, LOW);

digitalWrite (SSD_d, HIGH);

digitalWrite (SSD_e, HIGH);

digitalWrite (SSD_f, LOW);

digitalWrite (SSD_g, HIGH);

}

 

void SSD_3()

{

digitalWrite (SSD_a, HIGH);

digitalWrite (SSD_b, HIGH);

digitalWrite (SSD_c, HIGH);

digitalWrite (SSD_d, HIGH);

digitalWrite (SSD_e, LOW);

digitalWrite (SSD_f, LOW);

digitalWrite (SSD_g, HIGH);

}

 

void SSD_4()

{

digitalWrite (SSD_a, LOW);

digitalWrite (SSD_b, HIGH);

digitalWrite (SSD_c, HIGH);

digitalWrite (SSD_d, LOW);

digitalWrite (SSD_e, LOW);

digitalWrite (SSD_f, HIGH);

digitalWrite (SSD_g, HIGH);

}

 

void SSD_5()

{

digitalWrite (SSD_a, HIGH);

digitalWrite (SSD_b, LOW);

digitalWrite (SSD_c, HIGH);

digitalWrite (SSD_d, HIGH);

digitalWrite (SSD_e, LOW);

digitalWrite (SSD_f, HIGH);

digitalWrite (SSD_g, HIGH);

}

 

void SSD_6()

{

digitalWrite (SSD_a, HIGH);

digitalWrite (SSD_b, LOW);

digitalWrite (SSD_c, HIGH);

digitalWrite (SSD_d, HIGH);

digitalWrite (SSD_e, HIGH);

digitalWrite (SSD_f, HIGH);

digitalWrite (SSD_g, HIGH);

}

 

void SSD_7()

{

digitalWrite (SSD_a, HIGH);

digitalWrite (SSD_b, HIGH);

digitalWrite (SSD_c, HIGH);

digitalWrite (SSD_d, LOW);

digitalWrite (SSD_e, LOW);

digitalWrite (SSD_f, LOW);

digitalWrite (SSD_g, LOW);

}

 

 

void SSD_8()

{

digitalWrite (SSD_a, HIGH);

digitalWrite (SSD_b, HIGH);

digitalWrite (SSD_c, HIGH);

digitalWrite (SSD_d, HIGH);

digitalWrite (SSD_e, HIGH);

digitalWrite (SSD_f, HIGH);

digitalWrite (SSD_g, HIGH);

}

 

 

void SSD_9()

{

digitalWrite (SSD_a, HIGH);

digitalWrite (SSD_b, HIGH);

digitalWrite (SSD_c, HIGH);

digitalWrite (SSD_d, LOW);

digitalWrite (SSD_e, LOW);

digitalWrite (SSD_f, HIGH);

digitalWrite (SSD_g, HIGH);

}

 

Run the experiment

After the connections, connect the Arduino to the PC using Arduino USB cable and transfer the program to Arduino using Arduino IDE software.

USB cable is also providing the power to the Arduino board so, no need to supply separately to the Arduino.

Since in the program we glowing the LEDs required for the digits 0-9, so it will show the digits from 0 to 9 every second.

 











 

Comments

Popular posts from this blog

How to Make Automatic Room Light Controller Without Microcontroller

You must have noticed in some offices or hotels, when nobody is in gallery or washroom, the light remains OFF but when somebody enters the place, light switches ON automatically. In this post I am going to teach you how to make this circuit. Before going ahead I would like to tell you that this is VERY EASY circuit. For this circuit the material we need is… PIR Motion sensor General Purpose PCB - 5x5 cm. Transistor 2222N – 1 No. Relay 5V – 1 No. 1K/0.250W – 2 Nos. 10K/0.250W – 1 No. IN4007 – 2 Nos. LED 3mm – 1 No. Connector – 4 Nos. Few wires. Relay Circuit Concept : We can use any relay of 12V, 24V, 5V etc. but we have to consider power supply or battery we will use. Since 5V power supply is easily available and 9V battery can also be used for 5V output (after using 7805 regulator if needed). So I am using 5V relay. PIR sensor has three terminals, One for 5Vdc Second for Gnd (0V). Third for

How to drive high voltage/current load by small voltage signal from a microcontroller?

Sometimes we need to control or drive a high voltage and heavy current load by a small voltage signal. For example, if you want to control water motor with your microcontroller output. We know that microcontroller gives only 5v output which is not sufficient to drive a heavy motor. This circuit, about which this post is, is very-very useful for electronics engineer and hobbyist. So pay attention! For this circuit the material we need is… General Purpose PCB - 5x5 cm. Transistor KN 2222A (TO-92) - 1 No. Relay 5V – 1 No. 1K/0.250W – 2 Nos. 10K/0.250W – 1 No. IN4007 – 2 Nos. LED 3mm – 1 No. Connector – 4 Nos. Few wires. Tools. Concept: Weak signal triggers the transistor and transistor acts as a switch for the relay. You can use any relay of 12V, 24V, 5V etc. but we have to consider power supply or battery we will use. Since 5V power supply is easily available and 9V battery can also be used for 5V output (after using 7805 regulator if needed).

Parking Gate with Password Protected Entry | ElectroMech Lab | Arduino

Hello Friends, This project is for password/PIN protected Parking gate. This is very interesting project. I hope you like it. Material: Arduino UNO - 1 No. Servo Motor - 1 No. IR Sensor - 1 No. 4x4 Keypad - 1 No. 9V Battery - 1 No. Toy Car - As per your wish. 10 Kohm Resistor - 1 No. Sketch:  // This code is for password/PIN protected Parking Gate. #include <Keypad.h> #include <Servo.h> Servo myservo;  // create servo object to control a servo int exitSensor= 10;   // pin 10 is connected to out sensor, when vehicle is passed after toll crossing //******************************************************** keypad initialisation  ************************************ char* password = "1245"; // if this is changed then modification is needed in loop section validating the keys const byte ROWS = 4; //four rows const byte COLS = 4; //three columns char keys[ROWS][COLS] = {       {'1', '2', '3', 'A'},   {'4', '5', '6',