Answer the question
In order to leave comments, you need to log in
After the reset, the first LED does not light up, why?
Hello! 8 LEDs are connected, each lights up after 1 second. When you press the button, they are extinguished and light up again, all except the first one, why?
the code:
int led[] = {3,4,5,6,7,8,9,10};
int c=0;
void on(int pin){
digitalWrite(pin, HIGH);
}
void off(int pin){
digitalWrite(pin, LOW);
}
void setup(){
pinMode(2, INPUT);
attachInterrupt(0, button, RISING);
for(c=0; c<sizeof(led); c++){
pinMode(led[c], OUTPUT);
}
}
void loop(){
for(c=0; c<sizeof(led); c++){
on(led[c]);
delay(1000);
}
}
void button(){
for(c=0; c<sizeof(led); c++){
off(led[c]);
}
c=0;
}
Answer the question
In order to leave comments, you need to log in
void loop(){
for(c=0; c<sizeof(led); c++){
on(led[c]);
delay(1000);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question