Hello,
I am begginer and I am tryign to do this. please help me...
Each time the button is pressed, the four LEDs are turned on in turn, -> I did it,
and then, I want to turn off 4 LEDs in turn, each time I press the button.
I searched various tutorials on the web, but all about 1 LED or no push button.
Thanks,
int ledPins[] = {7, 9, 11, 13};
int buttonPin = 2;
int preButton;
int buttonState;
int whichLedPin;
void setup() {
int index;
for (index = 0 ; index <= 3 ; index++) {
pinMode(ledPins[index], OUTPUT);
}
pinMode(buttonPin, INPUT);
}
void loop() {
int buttonState = digitalRead(buttonPin);
if (buttonState == HIGH && preButton == LOW) {
whichLedPin++;
if (whichLedPin > 3) {
whichLedPin = 0;
}
delay(50);
}
preButton = buttonState;
for (int i = 0; i < 4; i++) {
if (whichLedPin == i) {
digitalWrite(ledPins*, HIGH);*
-
} *
-
for (int i = 0; i > 4; i--) {*
-
if (whichLedPin == i) {*
_ digitalWrite(ledPins*, LOW);_
_ } _
_ }_
_ }*_