Arduino 7 Segment LED Display and Counter
This is a simple 0 to 9 counter circuit constructed using Arduino! Here, a common cathode 7-segment LED display is connected to Arduino for displaying the digits.
The whole circuit can be powered from a standard 9V PP3/6F22 battery, or from any suitable Arduino power adaptor.
The whole circuit can be powered from a standard 9V PP3/6F22 battery, or from any suitable Arduino power adaptor.
The seven segment display is infact a very simple device. It is a combination of 8 LEDs (the decimal point -DP- is the 8th), which can be arranged so that different combinations can be used to make numerical digits.
Details of a common cathode type 7 segment LED display is shown here. Note that pins 3 and 8 of the display is the cathode terminals.
Just follow the schematic circuit diagram to make the entire project.
Arduino pins 2, 3, 4, 5, 6, 7 and 8 should go to Display pins 7, 6, 4, 2, 1, 9 and 10 in correct order. In case of any doubt refer this table.
Arduino pins 2, 3, 4, 5, 6, 7 and 8 should go to Display pins 7, 6, 4, 2, 1, 9 and 10 in correct order. In case of any doubt refer this table.
Connecting the display pins directly to Arduino I/O pins is not a good practice. For testing purpose only one 330 Ohm resistor (R2) is added between ground rail (0V) and the common cathode pins (3 & 8). It is better to directly connect pins 3 & 8 of the display to ground rail. Next add a 330 Ohm resistor between each of the other connections to the Arduino.
Programming
Programming
int pausa=1000;
void setup()
{
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
}
void display (int a, int b, int c, int d, int e, int f, intg)
{
digitalWrite (2,a);
digitalWrite (3,b);
digitalWrite (4,c);
digitalWrite (5,d);
digitalWrite (6,e);
digitalWrite (7,f);
digitalWrite (8,g);
}
void loop()
{
display (1,1,1,1,1,1,0); //write 0
delay(pausa);
display (0,1,1,0,0,0,0); //write 1
delay(pausa);
display (1,1,0,1,1,0,1); //write 2
delay(pausa);
display (1,1,1,1,0,0,1); //write 3
delay(pausa);
display (0,1,1,0,0,1,1); //write 4
delay(pausa);
display (1,0,1,1,0,1,1); //write 5
delay(pausa);
display (1,0,1,1,1,1,1); //write 6
delay(pausa);
display (1,1,1,0,0,0,0); //write 7
delay(pausa);
display (1,1,1,1,1,1,1); //write 8
delay(pausa);
display (1,1,1,0,0,1,1); //write 9
delay(pausa);
}