Hi
In the attached sketch i hoped to achieve 4 LED's blinking at a rate of 1Hz to 20Hz , each controlled by a pot.
It uploaded , but all LED's were on and blinking at 2.6KHz with no control by each pot.
Any thoughts.
In the attached sketch i hoped to achieve 4 LED's blinking at a rate of 1Hz to 20Hz , each controlled by a pot.
It uploaded , but all LED's were on and blinking at 2.6KHz with no control by each pot.
Any thoughts.
Code:
int Ledpin[] = {8, 9, 10, 11};
int Potpin[] = {A0, A1, A2, A3};
boolean state[4];
void setup() {
for (int i; i < 4; i++)
{ pinMode(Ledpin[i], OUTPUT);
pinMode(Potpin[i], INPUT);
state[i] = LOW;
}
}
void loop() {
int potValue = analogRead(Potpin);
int Potpin = map (potValue , 0, 1023, 500 , 25); // 1Hz to 20Hz
for (int i; i < 4; i++)
{ if (digitalRead(Potpin);
state[i] = !state[i]);
digitalWrite(Ledpin[i], state[i]);
}
}
Last edited: