Seven segment with Arduino

Seven Segment Programming For Arduino UNO








-------------------------------------------------------------------------------------------------------------
CODE
---------------------------------------------------------------------------------------------------------------
int a=7; 
int b=6; 
int d=9;
int e=8; 
int f=5; 
int g=4; 
int c=10;

void setup() {
pinMode (a,OUTPUT);pinMode (b,OUTPUT);pinMode (c,OUTPUT);
pinMode (d,OUTPUT);pinMode (e,OUTPUT);pinMode (f,OUTPUT);pinMode (g,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(a,HIGH);digitalWrite(b,HIGH);digitalWrite(c,HIGH);
  digitalWrite(d,HIGH);digitalWrite(e,HIGH);digitalWrite(f,HIGH);
  digitalWrite(g,HIGH);

//for 1 
digitalWrite(b,LOW);digitalWrite(c,LOW);
delay(1000);                                                                                                                                                   
digitalWrite(a,HIGH);digitalWrite(b,HIGH);digitalWrite(c,HIGH);
  digitalWrite(d,HIGH);digitalWrite(e,HIGH);digitalWrite(f,HIGH);
  digitalWrite(g,HIGH);

// for 2
digitalWrite(a,LOW);digitalWrite(b,LOW);
digitalWrite(g,LOW);digitalWrite(e,LOW);
digitalWrite(d,LOW);
delay(1000);
digitalWrite(a,HIGH);digitalWrite(b,HIGH);digitalWrite(c,HIGH);
  digitalWrite(d,HIGH);digitalWrite(e,HIGH);digitalWrite(f,HIGH);
  digitalWrite(g,HIGH);

//for 3
digitalWrite(a,LOW);digitalWrite(b,LOW);
digitalWrite(g,LOW);digitalWrite(c,LOW);
digitalWrite(d,LOW);delay(1000);
digitalWrite(a,HIGH);digitalWrite(b,HIGH);digitalWrite(c,HIGH);
  digitalWrite(d,HIGH);digitalWrite(e,HIGH);digitalWrite(f,HIGH);
  digitalWrite(g,HIGH);
// for 4
digitalWrite(f,LOW);digitalWrite(g,LOW);
digitalWrite(b,LOW);digitalWrite(c,LOW);
delay(1000);
digitalWrite(a,HIGH);digitalWrite(b,HIGH);digitalWrite(c,HIGH);
  digitalWrite(d,HIGH);digitalWrite(e,HIGH);digitalWrite(f,HIGH);
  digitalWrite(g,HIGH);

// for 5
digitalWrite(a,LOW);digitalWrite(f,LOW);
digitalWrite(g,LOW);digitalWrite(c,LOW);
digitalWrite(d,LOW);delay(1000);
digitalWrite(a,HIGH);digitalWrite(b,HIGH);digitalWrite(c,HIGH);
  digitalWrite(d,HIGH);digitalWrite(e,HIGH);digitalWrite(f,HIGH);
  digitalWrite(g,HIGH);

// for 6
digitalWrite(a,LOW);digitalWrite(f,LOW);
digitalWrite(g,LOW);digitalWrite(c,LOW);
digitalWrite(d,LOW);digitalWrite(e,LOW);
delay(1000);
digitalWrite(a,HIGH);digitalWrite(b,HIGH);digitalWrite(c,HIGH);
  digitalWrite(d,HIGH);digitalWrite(e,HIGH);digitalWrite(f,HIGH);
  digitalWrite(g,HIGH);
// for 7
digitalWrite(a,LOW);digitalWrite(b,LOW);
digitalWrite(c,LOW);delay(1000);
digitalWrite(a,HIGH);digitalWrite(b,HIGH);digitalWrite(c,HIGH);
  digitalWrite(d,HIGH);digitalWrite(e,HIGH);digitalWrite(f,HIGH);
  digitalWrite(g,HIGH);

// for 8
digitalWrite(a,LOW);digitalWrite(f,LOW);
digitalWrite(g,LOW);digitalWrite(b,LOW);
digitalWrite(e,LOW);digitalWrite(d,LOW);
digitalWrite(c,LOW);delay(1000);
digitalWrite(a,HIGH);digitalWrite(b,HIGH);digitalWrite(c,HIGH);
  digitalWrite(d,HIGH);digitalWrite(e,HIGH);digitalWrite(f,HIGH);
  digitalWrite(g,HIGH);
// for 9
digitalWrite(a,LOW);digitalWrite(f,LOW);
digitalWrite(g,LOW);digitalWrite(b,LOW);
digitalWrite(d,LOW);digitalWrite(c,LOW);
delay(1000);
digitalWrite(a,HIGH);digitalWrite(b,HIGH);digitalWrite(c,HIGH);
  digitalWrite(d,HIGH);digitalWrite(e,HIGH);digitalWrite(f,HIGH);
  digitalWrite(g,HIGH);

//for 0
digitalWrite(a,LOW);digitalWrite(f,LOW);
digitalWrite(b,LOW);digitalWrite(e,LOW);
digitalWrite(d,LOW);digitalWrite(c,LOW);
delay(1000);
digitalWrite(a,HIGH);digitalWrite(b,HIGH);digitalWrite(c,HIGH);
  digitalWrite(d,HIGH);digitalWrite(e,HIGH);digitalWrite(f,HIGH);
  digitalWrite(g,HIGH)

}

-------------------------------------------------------------------------------------------------------------------







No comments:

Post a Comment

Wifi Home automation Diy kit

 Wifi Home automation Diy kit By Manmohan Pal Wifi Home Automation Kit Hi, This is Manmohan Pal, I am glad to present a DIY kit for Home Aut...