I am trying to make some Arduino code count on a 7 segment display. I have the wiring all right but this code will not delay one second and go to next function. Any ideas?
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(3,OUTPUT); pinMode(4,OUTPUT); pinMode(5,OUTPUT);
pinMode(6,OUTPUT); pinMode(7,OUTPUT); pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
}
void n0() {
digitalWrite(3,LOW); digitalWrite(4,LOW); digitalWrite(5,LOW);
digitalWrite(6,LOW); digitalWrite(7,LOW); digitalWrite(8,LOW);
digitalWrite(9,HIGH);
}
void ndash() {
digitalWrite(3,HIGH); digitalWrite(4,HIGH); digitalWrite(5,HIGH);
digitalWrite(6,HIGH); digitalWrite(7,HIGH); digitalWrite(8,HIGH);
digitalWrite(9,LOW);
}
void loop() {
n0();
delay(1000);
ndash();
}
Best Answer
If I understand your symptoms correctly, you need a second delay.
Here's what the code looks like if you executed the loop a few times:
ndash() is only displayed for however long it takes for n0() to execute, which is probably too fast to see.