simple 7 segment display driver using arduino uno
Here is a simple code for arduino for driving a 7 segment display.
arduino
int timer = 500; // The higher the number, the slower the timing.
void setup() {
// use a for loop to initialize each pin as an output:
for (int thisPin = 0; thisPin < 14; thisPin++) {
pinMode(thisPin, OUTPUT);
}
}
void loop() {
// loop from the lowest pin to the highest:
for (int thisPin = 0; thisPin < 14; thisPin++) {
// turn the pin on:
digitalWrite(thisPin, HIGH);
delay(timer);
// turn the pin off:
digitalWrite(thisPin, LOW);
delay(timer);
}
// loop from the highest pin to the lowest:
for (int thisPin = 7; thisPin >= 2; thisPin--) {
// turn the pin on:
digitalWrite(thisPin, HIGH);
delay(timer);
// turn the pin off:
digitalWrite(thisPin, LOW);
}
}
Here this code uses for loop for the selection of o/p pins and also for the state of each pin
steps
Here is a simple code for arduino for driving a 7 segment display.
arduino
disply
code
int timer = 500; // The higher the number, the slower the timing.
void setup() {
// use a for loop to initialize each pin as an output:
for (int thisPin = 0; thisPin < 14; thisPin++) {
pinMode(thisPin, OUTPUT);
}
}
void loop() {
// loop from the lowest pin to the highest:
for (int thisPin = 0; thisPin < 14; thisPin++) {
// turn the pin on:
digitalWrite(thisPin, HIGH);
delay(timer);
// turn the pin off:
digitalWrite(thisPin, LOW);
delay(timer);
}
// loop from the highest pin to the lowest:
for (int thisPin = 7; thisPin >= 2; thisPin--) {
// turn the pin on:
digitalWrite(thisPin, HIGH);
delay(timer);
// turn the pin off:
digitalWrite(thisPin, LOW);
}
}
Here this code uses for loop for the selection of o/p pins and also for the state of each pin
steps
- connect the ground and vcc of the display to the grnd and the +5v pin of arduino respectively.
- connect the a,b,c,d,e,f, pin of ur display to the output pins(1-13) of arduino. ( u can connect it in any order as u like)
- connect ur arduino to ur lap or pc
- coppy the lnk above and paste it to the arduino Ide
- upload the programme
No comments:
Post a Comment