4 Digit 7 Segment Led Display Application
4 Digit 7 Segment Led Display Application
4 Digit 7 Segment Led Display Application
4 Digit 7 Segment Led Display Application

4 Digit 7 Segment Led Display Application

In this application, we will try a counter with a 4 digit 7 segment led display.
7 Segment display is a common cathode display. 5461AS coded led screen is a very common led display in the market. And it has four cathode tips. These are d1, d2, d3 and d4. We will light the LEDs of the screen using the digital pins of the Arduino board.


The four-digit 7-segment display has 10 pins. These are: a, b, c, d, e, f, g, point and four Cathode (GND) tips.

Youtube Channel:


a, b, c, d, e, f, g, point pins are connected to the digital output pins of the Arduino board with 1K resistors. The dot pins a, b, c, d, e, f, g, are connected to the digital outputs d13, d12, d11, d10, d9, d8, d7, d6 of the board. d5, d4, d3 and d2 are connected to the base terminals of the BC547 transistors. We used 47K resistors to control the base current.


In the Arduino code screen, we defined a sequence for each digit and specified which leds to light. In the codes below, we exported the values ​​in this array with the "digitalWrite" command with the help of a "for" loop.

Arduino Codes: 

//--------- -{a,b,c,d,e,f,g,dot}
  int s0[] = {1,1,1,1,1,1,0,0};
  int s1[] = {0,1,1,0,0,0,0,0};
  int s2[] = {1,1,0,1,1,0,1,0};
  int s3[] = {1,1,1,1,0,0,1,0};
  int s4[] = {0,1,0,0,1,1,1,0};
  int s5[] = {1,0,1,1,0,1,1,0};
  int s6[] = {1,0,1,1,1,1,1,0};
  int s7[] = {1,1,1,0,0,0,0,0};
  int s8[] = {1,1,1,1,1,1,1,0};
  int s9[] = {1,1,1,1,0,1,1,0};
  int s10[]= {1,1,1,1,1,1,0,0};
  
void setup()
{
  
  pinMode(13, OUTPUT);  // a 
  pinMode(12, OUTPUT);  // b 
  pinMode(11, OUTPUT);  // c 
  pinMode(10, OUTPUT);  // d 
  pinMode(9, OUTPUT);    // e 
  pinMode(8, OUTPUT);  // f
  pinMode(7, OUTPUT);  // g 
  pinMode(6, OUTPUT);  //DOT LED  <-----------
  
 }
void loop()
{
  // test routing-----------------------
  for(int i=6;i<14;i++)  {
    digitalWrite(i,HIGH); delay(50);digitalWrite(i,LOW);
    }
    for(int i=14;i>5;i--)  {
    digitalWrite(i,HIGH); delay(50);digitalWrite(i,LOW);
    }
// test routing-----------------------END
for(int i=1;i<10;i++) { digitalWrite(14-i,s0[i-1]); delay(50);digitalWrite(14-i,s0[i-1]);}; delay(100);
for(int i=1;i<10;i++) { digitalWrite(14-i,s1[i-1]); delay(50);digitalWrite(14-i,s1[i-1]);}  delay(100);
for(int i=1;i<10;i++) { digitalWrite(14-i,s2[i-1]); delay(50);digitalWrite(14-i,s2[i-1]);}    delay(100);
for(int i=1;i<10;i++) { digitalWrite(14-i,s3[i-1]); delay(50);digitalWrite(14-i,s3[i-1]);}; delay(100);
for(int i=1;i<10;i++) { digitalWrite(14-i,s4[i-1]); delay(50);digitalWrite(14-i,s4[i-1]);}  delay(100);
for(int i=1;i<10;i++) { digitalWrite(14-i,s5[i-1]); delay(50);digitalWrite(14-i,s5[i-1]);}    delay(100);
for(int i=1;i<10;i++) { digitalWrite(14-i,s6[i-1]); delay(50);digitalWrite(14-i,s6[i-1]);}; delay(100);
for(int i=1;i<10;i++) { digitalWrite(14-i,s7[i-1]); delay(50);digitalWrite(14-i,s7[i-1]);}  delay(100);
for(int i=1;i<10;i++) { digitalWrite(14-i,s8[i-1]); delay(50);digitalWrite(14-i,s8[i-1]);}    delay(100);
for(int i=1;i<10;i++) { digitalWrite(14-i,s9[i-1]); delay(50);digitalWrite(14-i,s9[i-1]);}; delay(100);
    
    
}