I have made this programming but I want all pins to be LOW in the if statement.What have I made wrong?
int timer = 100;
const int ledPins[] = {
2, 7, 4, 6, 5, 3 };
int pinCount = 6;
const int analogPin = 0;
const int threshold = 400;
void setup() {
int thisPin;
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
pinMode(ledPins[thisPin], OUTPUT);
}
}
void loop() {
int analogValue = analogRead(analogPin);
if (analogValue > threshold) {
for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) {
digitalWrite(ledPins[thisPin], LOW);
}
}
else {
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
digitalWrite(ledPins[thisPin], HIGH);
delay(timer);
digitalWrite(ledPins[thisPin], LOW);
}
}
// loop from the highest pin to the lowest:
for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) {
// turn the pin on:
digitalWrite(ledPins[thisPin], HIGH);
delay(timer);
// turn the pin off:
digitalWrite(ledPins[thisPin], LOW);
}
}
Thanks