loading
Picture of 7 Segment Display On Arduino

This instructable shows how to display 0-9 digits on 7 Segment Display using Arduino.

What do you need:

  • Arduino Uno 3
  • 7 Seven Segment Display
  • 2 x 220 Ohm Resistors
  • Jumper Wires

 
Remove these adsRemove these ads by Signing Up

Step 1: Making Connections

Picture of Making Connections
7 Segment Fritzing Sketch.PNG

Connect the pins described below:

  1. Arduino Pin 2 to Pin 9.
  2. Arduino Pin 3 to Pin 10.
  3. Arduino Pin 4 to Pin 4.

  4. Arduino Pin 5 to Pin 2..

  5. Arduino Pin 6 to Pin 1.

  6. Arduino Pin 8 to Pin 7.

  7. Arduino Pin 9 to Pin 6.

  8. GND to Pin 3 and Pin 8 each connected with 220 ohm resistors.

Step 2: Arduino Code

int a = 2;  //For displaying segment "a"
int b = 3;  //For displaying segment "b"
int c = 4;  //For displaying segment "c"
int d = 5;  //For displaying segment "d"
int e = 6;  //For displaying segment "e"
int f = 8;  //For displaying segment "f"
int g = 9;  //For displaying segment "g"
void setup() {               
  pinMode(a, OUTPUT);  //A
  pinMode(b, OUTPUT);  //B
  pinMode(c, OUTPUT);  //C
  pinMode(d, OUTPUT);  //D
  pinMode(e, OUTPUT);  //E
  pinMode(f, OUTPUT);  //F
  pinMode(g, OUTPUT);  //G
}
void displayDigit(int digit)
{
 //Conditions for displaying segment a
 if(digit!=1 && digit != 4)
 digitalWrite(a,HIGH);
 
 //Conditions for displaying segment b
 if(digit != 5 && digit != 6)
 digitalWrite(b,HIGH);
 
 //Conditions for displaying segment c
 if(digit !=2)
 digitalWrite(c,HIGH);
 
 //Conditions for displaying segment d
 if(digit != 1 && digit !=4 && digit !=7)
 digitalWrite(d,HIGH);
 
 //Conditions for displaying segment e 
 if(digit == 2 || digit ==6 || digit == 8 || digit==0)
 digitalWrite(e,HIGH);
 
 //Conditions for displaying segment f
 if(digit != 1 && digit !=2 && digit!=3 && digit !=7)
 digitalWrite(f,HIGH);
 if (digit!=0 && digit!=1 && digit !=7)
 digitalWrite(g,HIGH);
 
}
void turnOff()
{
  digitalWrite(a,LOW);
  digitalWrite(b,LOW);
  digitalWrite(c,LOW);
  digitalWrite(d,LOW);
  digitalWrite(e,LOW);
  digitalWrite(f,LOW);
  digitalWrite(g,LOW);
}


void loop() {
 for(int i=0;i<10;i++)
 {
   displayDigit(i);
   delay(1000);
   turnOff();
 }
}
nfarrow made it!4 days ago
timer.png
ajmifaz made it!8 days ago

Connections which is in the description is wrong.

Connections which is in the circuit diagram is the correct one.

Correct description
Connect the pins described below:


  1. Arduino Pin 2 to Pin 7.
  2. Arduino Pin 3 to Pin 6.
  3. Arduino Pin 4 to Pin 4.
  4. Arduino Pin 5 to Pin 2.
  5. Arduino Pin 6 to Pin 1.
  6. Arduino Pin 8 to Pin 9.
  7. Arduino Pin 9 to Pin 10.
  8. GND to Pin 3 and Pin 8 each connected with 220 ohm resistors.
photo1355.jpg
sbyas1 year ago

Doesn't work correctly. could you tell me why.

SherMarri (author)  sbyas1 year ago

Confirm if you have exact same components? Have you made right connections? Copied all code?

me 2 bro.. not work correctly.. fix this if u can.

Connections which is in the circuit diagram is the correct one.

Connections which is in the description is wrong
Correct description
Connect the pins described below:


  1. Arduino Pin 2 to Pin 7.
  2. Arduino Pin 3 to Pin 6.
  3. Arduino Pin 4 to Pin 4.
  4. Arduino Pin 5 to Pin 2.
  5. Arduino Pin 6 to Pin 1.
  6. Arduino Pin 8 to Pin 9.
  7. Arduino Pin 9 to Pin 10.
  8. GND to Pin 3 and Pin 8 each connected with 220 ohm resistors.
ajmifaz sbyas8 days ago

Connections which is in the circuit diagram is the correct one.

Connections which is in the description is wrong
Correct description
Connect the pins described below:


  1. Arduino Pin 2 to Pin 7.
  2. Arduino Pin 3 to Pin 6.
  3. Arduino Pin 4 to Pin 4.
  4. Arduino Pin 5 to Pin 2.
  5. Arduino Pin 6 to Pin 1.
  6. Arduino Pin 8 to Pin 9.
  7. Arduino Pin 9 to Pin 10.
  8. GND to Pin 3 and Pin 8 each connected with 220 ohm resistors.
ktrantham sbyas10 months ago

HERE IS THE FIX!!!!!!!!!!!!!!!!!!! the code is defunct now due to newer IDE versions: to fix the code change in the line of Void Loop

for(int i=0;i<10;i++)

remove int after for(i=0;i<10;i++) < should look like this

and in the same Void loop add this line before the if statement

int 1;

so it should look like :

void loop()

{

int i;

for( i = 0; i< 10; i++);

{

DONE

doesn't work and when i change the code nothing happened and the connections in the picture aren't the same in the writting or the numbering were wrong

Connections which is in the circuit diagram is the correct one.

Connections which is in the description is wrong
Correct description
Connect the pins described below:


  1. Arduino Pin 2 to Pin 7.
  2. Arduino Pin 3 to Pin 6.
  3. Arduino Pin 4 to Pin 4.
  4. Arduino Pin 5 to Pin 2.
  5. Arduino Pin 6 to Pin 1.
  6. Arduino Pin 8 to Pin 9.
  7. Arduino Pin 9 to Pin 10.
  8. GND to Pin 3 and Pin 8 each connected with 220 ohm resistors.
navneet kaur5 months ago

It doesn't work...the connections done in circuit diagram and those given in description are different...which one is correct? The code works fine with the changes given in the comments.. can u tell me where lies the flaw?

Connections which is in the circuit diagram is the correct one.
Connections which is in the description is wrong
Correct description
Connect the pins described below:


  1. Arduino Pin 2 to Pin 7.
  2. Arduino Pin 3 to Pin 6.
  3. Arduino Pin 4 to Pin 4.
  4. Arduino Pin 5 to Pin 2.
  5. Arduino Pin 6 to Pin 1.
  6. Arduino Pin 8 to Pin 9.
  7. Arduino Pin 9 to Pin 10.
  8. GND to Pin 3 and Pin 8 each connected with 220 ohm resistors.
cristianoab made it!2 months ago

Works

IMG_20150529_224939.jpg
navneet kaur5 months ago

It doesn't work...the connections done in circuit diagram and those given in description are different...which one is correct? The code works fine with the changes given in the comments.. can u tell me where lies the flaw?

navneet kaur5 months ago

It doesn't work...the connections done in circuit diagram and those given in description are different...which one is correct? The code works fine with the changes given in the comments.. can u tell me where lies the flaw?

just for rate6 months ago

thank you a lot this works 100% with me :) :)

ktrantham10 months ago

HERE IS THE FIX!!!!!!!!!!!!!!!!!!! the code is defunct now due to newer IDE versions: to fix the code change in the line of Void Loop

for(int i=0;i<10;i++)

remove int after for(i=0;i<10;i++) < should look like this

and in the same Void loop add this line before the if statement

int 1;

so it should look like :

void loop()

{

int i;

for( i = 0; i< 10; i++);

{

DONE

ktrantham10 months ago

Code is defunct can you fix or identify problems in all if statements compile reports errors with all if"s

sbyas1 year ago
I do but when I turned the Arduino on then the 7 segment display was flashing on and off the letters.

Looks like it's all there....