Toll-Free Customer Support 24/7

 

const int sel1=27, sel2=14, sel3=12, sel4=13;                         //initializing selection pins -Port P3

const int a=16 ,b=17, c=5, d=18, e=19, f=21, g=22, dp=23;  //initializing data pins -Port P2

 

void setup()

{

pinMode(sel1,OUTPUT);                //declaring Selection Pins as output

pinMode(sel2,OUTPUT);

pinMode(sel3,OUTPUT);

pinMode(sel4,OUTPUT);

 

 digitalWrite(sel1,LOW);               //selecting all 4 digits of 7-Segment display by making it LOW

 digitalWrite(sel2,LOW);

 digitalWrite(sel3,LOW);

 digitalWrite(sel4,LOW);

 

pinMode(a,OUTPUT);                 //declaring data pins as output

pinMode(b,OUTPUT);

pinMode(c,OUTPUT);

pinMode(d,OUTPUT);

pinMode(e,OUTPUT);

pinMode(f,OUTPUT);

pinMode(g,OUTPUT);

pinMode(dp,OUTPUT);

delay(100);

}

 

void loop()

{

   // print 0

   digitalWrite(a,LOW);

   digitalWrite(b,LOW);

   digitalWrite(c,LOW);

   digitalWrite(d,LOW);

   digitalWrite(e,LOW);

   digitalWrite(f,LOW);

   digitalWrite(g,HIGH);

   digitalWrite(dp,LOW);

   delay(2000); 

  // print 1

   digitalWrite(a,HIGH);

   digitalWrite(b,LOW);

   digitalWrite(c,LOW);

   digitalWrite(d,HIGH);

   digitalWrite(e,HIGH);

   digitalWrite(f,HIGH);

   digitalWrite(g,HIGH);

   digitalWrite(dp,HIGH);

   delay(2000);

   

  // print 2

   digitalWrite(a,LOW);

   digitalWrite(b,LOW);

   digitalWrite(c,HIGH);

   digitalWrite(d,LOW);

   digitalWrite(e,LOW);

   digitalWrite(f,HIGH);

   digitalWrite(g,LOW);

   digitalWrite(dp,LOW);

   delay(2000);

   

  // print 3

   digitalWrite(a,LOW);

   digitalWrite(b,LOW);

   digitalWrite(c,LOW);

   digitalWrite(d,LOW);

   digitalWrite(e,HIGH);

   digitalWrite(f,HIGH);

   digitalWrite(g,LOW);

   digitalWrite(dp,LOW);

   delay(2000);

   

  // print 4

   digitalWrite(a,HIGH);

   digitalWrite(b,LOW);

   digitalWrite(c,LOW);

   digitalWrite(d,HIGH);

   digitalWrite(e,HIGH);

   digitalWrite(f,LOW);

   digitalWrite(g,LOW);

   digitalWrite(dp,LOW);

   delay(2000);

 

  // print 5

   digitalWrite(a,LOW);

   digitalWrite(b,HIGH);

   digitalWrite(c,LOW);

   digitalWrite(d,LOW);

   digitalWrite(e,HIGH);

   digitalWrite(f,LOW);

   digitalWrite(g,LOW);

   digitalWrite(dp,LOW);

   delay(2000);

   

  // print 6

   digitalWrite(a,LOW);

   digitalWrite(b,HIGH);

   digitalWrite(c,LOW);

   digitalWrite(d,LOW);

   digitalWrite(e,LOW);

   digitalWrite(f,LOW);

   digitalWrite(g,LOW);

   digitalWrite(dp,LOW);

   delay(2000);

 

  // print 7

   digitalWrite(a,LOW);

   digitalWrite(b,LOW);

   digitalWrite(c,LOW);

   digitalWrite(d,HIGH);

   digitalWrite(e,HIGH);

   digitalWrite(f,HIGH);

   digitalWrite(g,HIGH);

   digitalWrite(dp,HIGH);

   delay(2000);

   

  // print 8

   digitalWrite(a,LOW);

   digitalWrite(b,LOW);

   digitalWrite(c,LOW);

   digitalWrite(d,LOW);

   digitalWrite(e,LOW);

   digitalWrite(f,LOW);

   digitalWrite(g,LOW);

   digitalWrite(dp,LOW);

   delay(2000);

 

   // print 9

   digitalWrite(a,LOW);

   digitalWrite(b,LOW);

   digitalWrite(c,LOW);

   digitalWrite(d,LOW);

   digitalWrite(e,HIGH);

   digitalWrite(f,LOW);

   digitalWrite(g,LOW);

   digitalWrite(dp,LOW);

   delay(2000);  

  }

Back to top