I'm a new arduino user and I've found a trouble making a new project.
I'm tryna make a Formula 1 RPM lights bar. My intent was to let the LEDs light up while I press the button.
But when I press once for a really short time the button, all the LEDs turn on.
Please help me
P.S. Don't mind the pins name written in italian!
nt stato = 0;
#define ROSSO1 2
#define ROSSO2 3
#define ROSSO3 4
#define GIALLO1 9
#define GIALLO2 10
#define BTN 13
byte led[] = {ROSSO1, ROSSO2, ROSSO3, GIALLO1, GIALLO2};
void setup() {
for (int i = 0; i < 6; i++) {
pinMode (led[i], OUTPUT);
digitalWrite (led, LOW);
}
}
void loop() {
int i = 0;
stato = digitalRead(BTN);
if (stato == LOW) {
for (; stato == LOW; i++) {
digitalWrite(led[i], HIGH);
delay(500);
}
}
if (stato == HIGH) {
for (i = 4; stato == HIGH; i--) {
delay(500);
digitalWrite(led[i], LOW);
}
}
}