(Created page with "Category:Arduino Tutorials 680px")
 
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
[[Category:Arduino Tutorials]]
 
[[Category:Arduino Tutorials]]
 
[[File:Arduino Display Numbers on Seven Segment Display.JPG|680px]]
 
[[File:Arduino Display Numbers on Seven Segment Display.JPG|680px]]
 +
==Code==
 +
<syntaxhighlight>
 +
/*
 +
  Display 0 to 9 Numbers on 7Segment Display.
 +
*/
 +
// give it a name:
 +
int a = 2;
 +
int b = 3;
 +
int c = 4;
 +
int d = 5;
 +
int e = 6;
 +
int f = 7;
 +
int g = 8;
 +
// the setup routine runs once when you press reset:
 +
void setup() {               
 +
  // initialize the digital pin as an output.
 +
  pinMode(a, OUTPUT); 
 +
  pinMode(b, OUTPUT);
 +
  pinMode(c, OUTPUT);
 +
  pinMode(d, OUTPUT);
 +
  pinMode(e, OUTPUT);
 +
  pinMode(f, OUTPUT);
 +
  pinMode(g, OUTPUT);
 +
}
 +
// the loop routine runs over and over again forever:
 +
void loop() {
 +
  //Disply 0
 +
  digitalWrite(a, HIGH); 
 +
  digitalWrite(b, HIGH); 
 +
  digitalWrite(c, HIGH); 
 +
  digitalWrite(d, HIGH); 
 +
  digitalWrite(e, HIGH);
 +
  digitalWrite(f, HIGH);
 +
  digitalWrite(g, LOW);
 +
  delay(500); 
 +
  //Disply 1
 +
  digitalWrite(a, LOW); 
 +
  digitalWrite(b, HIGH); 
 +
  digitalWrite(c, HIGH); 
 +
  digitalWrite(d, LOW); 
 +
  digitalWrite(e, LOW);
 +
  digitalWrite(f, LOW);
 +
  digitalWrite(g, LOW);
 +
  delay(500); 
 +
  //Disply 2
 +
  digitalWrite(a, HIGH); 
 +
  digitalWrite(b, HIGH); 
 +
  digitalWrite(c, LOW); 
 +
  digitalWrite(d, HIGH); 
 +
  digitalWrite(e, HIGH);
 +
  digitalWrite(f, LOW);
 +
  digitalWrite(g, HIGH);
 +
  delay(500);
 +
  //Disply 3
 +
  digitalWrite(a, HIGH); 
 +
  digitalWrite(b, HIGH); 
 +
  digitalWrite(c, HIGH); 
 +
  digitalWrite(d, HIGH); 
 +
  digitalWrite(e, LOW);
 +
  digitalWrite(f, LOW);
 +
  digitalWrite(g, HIGH);
 +
  delay(500);
 +
  //Disply 4
 +
  digitalWrite(a, LOW); 
 +
  digitalWrite(b, HIGH); 
 +
  digitalWrite(c, HIGH); 
 +
  digitalWrite(d, LOW); 
 +
  digitalWrite(e, LOW);
 +
  digitalWrite(f, HIGH);
 +
  digitalWrite(g, HIGH);
 +
  delay(500);
 +
  //Disply 5
 +
 +
  digitalWrite(a, HIGH); 
 +
  digitalWrite(b, LOW); 
 +
  digitalWrite(c, HIGH); 
 +
  digitalWrite(d, HIGH); 
 +
  digitalWrite(e, LOW);
 +
  digitalWrite(f, HIGH);
 +
  digitalWrite(g, HIGH);
 +
  delay(500); 
 +
    //Disply 6
 +
  digitalWrite(a, HIGH); 
 +
  digitalWrite(b, LOW); 
 +
  digitalWrite(c, HIGH); 
 +
  digitalWrite(d, HIGH); 
 +
  digitalWrite(e, HIGH);
 +
  digitalWrite(f, HIGH);
 +
  digitalWrite(g, HIGH);
 +
  delay(500); 
 +
    //Disply 7
 +
  digitalWrite(a, HIGH); 
 +
  digitalWrite(b, HIGH); 
 +
  digitalWrite(c, HIGH); 
 +
  digitalWrite(d, LOW); 
 +
  digitalWrite(e, LOW);
 +
  digitalWrite(f, LOW);
 +
  digitalWrite(g, LOW);
 +
  delay(500); 
 +
  //Disply 8
 +
  digitalWrite(a, HIGH); 
 +
  digitalWrite(b, HIGH); 
 +
  digitalWrite(c, HIGH); 
 +
  digitalWrite(d, HIGH); 
 +
  digitalWrite(e, HIGH);
 +
  digitalWrite(f, HIGH);
 +
  digitalWrite(g, HIGH);
 +
  delay(500); 
 +
    //Disply 9
 +
  digitalWrite(a, HIGH); 
 +
  digitalWrite(b, HIGH); 
 +
  digitalWrite(c, HIGH); 
 +
  digitalWrite(d, HIGH); 
 +
  digitalWrite(e, LOW);
 +
  digitalWrite(f, HIGH);
 +
  digitalWrite(g, HIGH);
 +
  delay(500); 
 +
  }
 +
 +
</syntaxhighlight>
 +
=Demo Video=
 +
{{#ev:youtubehd|jFxi2i4laNs|640}}
 +
{{DISQUS}}

Latest revision as of 12:08, 19 September 2014

Arduino Display Numbers on Seven Segment Display.JPG

Code

/*
  Display 0 to 9 Numbers on 7Segment Display.
 */
// give it a name:
int a = 2;
int b = 3;
int c = 4;
int d = 5;
int e = 6;
int f = 7;
int g = 8;
// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(a, OUTPUT);   
  pinMode(b, OUTPUT); 
  pinMode(c, OUTPUT); 
  pinMode(d, OUTPUT); 
  pinMode(e, OUTPUT); 
  pinMode(f, OUTPUT); 
  pinMode(g, OUTPUT); 
}
// the loop routine runs over and over again forever:
void loop() {
   //Disply 0
  digitalWrite(a, HIGH);   
  digitalWrite(b, HIGH);  
  digitalWrite(c, HIGH);   
  digitalWrite(d, HIGH);   
  digitalWrite(e, HIGH);
  digitalWrite(f, HIGH);
  digitalWrite(g, LOW);
  delay(500);  
  //Disply 1
  digitalWrite(a, LOW);   
  digitalWrite(b, HIGH);  
  digitalWrite(c, HIGH);   
  digitalWrite(d, LOW);   
  digitalWrite(e, LOW);
  digitalWrite(f, LOW);
  digitalWrite(g, LOW);
  delay(500);  
  //Disply 2
  digitalWrite(a, HIGH);   
  digitalWrite(b, HIGH);  
  digitalWrite(c, LOW);   
  digitalWrite(d, HIGH);   
  digitalWrite(e, HIGH);
  digitalWrite(f, LOW);
  digitalWrite(g, HIGH);
   delay(500); 
  //Disply 3 
  digitalWrite(a, HIGH);   
  digitalWrite(b, HIGH);  
  digitalWrite(c, HIGH);   
  digitalWrite(d, HIGH);   
  digitalWrite(e, LOW);
  digitalWrite(f, LOW);
  digitalWrite(g, HIGH);
   delay(500); 
  //Disply 4 
  digitalWrite(a, LOW);   
  digitalWrite(b, HIGH);  
  digitalWrite(c, HIGH);   
  digitalWrite(d, LOW);   
  digitalWrite(e, LOW);
  digitalWrite(f, HIGH);
  digitalWrite(g, HIGH);
   delay(500); 
  //Disply 5 
 
  digitalWrite(a, HIGH);   
  digitalWrite(b, LOW);  
  digitalWrite(c, HIGH);   
  digitalWrite(d, HIGH);   
  digitalWrite(e, LOW);
  digitalWrite(f, HIGH);
  digitalWrite(g, HIGH);
   delay(500);  
    //Disply 6
  digitalWrite(a, HIGH);   
  digitalWrite(b, LOW);  
  digitalWrite(c, HIGH);   
  digitalWrite(d, HIGH);   
  digitalWrite(e, HIGH);
  digitalWrite(f, HIGH);
  digitalWrite(g, HIGH);
   delay(500);  
    //Disply 7
  digitalWrite(a, HIGH);   
  digitalWrite(b, HIGH);  
  digitalWrite(c, HIGH);   
  digitalWrite(d, LOW);   
  digitalWrite(e, LOW);
  digitalWrite(f, LOW);
  digitalWrite(g, LOW);
   delay(500);  
   //Disply 8
  digitalWrite(a, HIGH);   
  digitalWrite(b, HIGH);  
  digitalWrite(c, HIGH);   
  digitalWrite(d, HIGH);   
  digitalWrite(e, HIGH);
  digitalWrite(f, HIGH);
  digitalWrite(g, HIGH);
   delay(500);  
     //Disply 9
  digitalWrite(a, HIGH);   
  digitalWrite(b, HIGH);  
  digitalWrite(c, HIGH);   
  digitalWrite(d, HIGH);   
  digitalWrite(e, LOW);
  digitalWrite(f, HIGH);
  digitalWrite(g, HIGH);
   delay(500);  
  }

Demo Video