Anyone got any ideas of how to make this code i found do random multiple LEDs at time instead of just 1?
// LED twinkler: LEDs on pins 2 to 13. each with 470 ohams to ground pin
// Pot wiper to A0. ends to +5v and ground
int Pin = 0, Locpct = 0, activeLED = 0, onTime = 10, potPin = 0;
void setup(){
// set pin mode and lights each led in sequance
for(Pin = 2; Pin < 14; Pin++){
pinMode(Pin,OUTPUT);
digitalWrite(Pin,HIGH);
delay(500);
digitalWrite(Pin,LOW);
}
}
void loop(){
//only one random LED on at a time when pot is above center
while(analogRead(2) <= 511){
onTime = map(analogRead(potPin),0,511,2,100);
activeLED = (random(2,14));
digitalWrite(activeLED,HIGH);
delay(random(onTime, onTime * 5));
digitalWrite(activeLED,LOW);
}
// LEDs on and Off Randomly when pot is below center
while(analogRead(potPin) > 511){
onTime = map(analogRead(2),512,1023,100,2);
digitalWrite(activeLED,HIGH);
delay(random(onTime, onTime *5));
digitalWrite(random(2,14),LOW);
}
}