Hi, I am really stuck here. I have a sketch that randomly flashes 5 LEDs. It works just as I want it to. I also have two potentiometers in the circuit to control the length of time each LED is lit and one to control the lag between the time the next one will light. ...like I said, everything is working as I originally wanted.
Now.... I have a new plan! I still want 5 LEDs with the random seed. Only one led can be lit at a time, (as it currently does). But instead of timing them to the off state, is it possible to use a momentary switch to interrupt the LED that's on, continue with the preprogrammed delay, fire the next LED chosen by the random seed....
Basically I'm looking to add a holding circuit.
Can someone please give me an idea or direction to go in?
Please, you must show us your complete sketch. Attach your code using the </> icon on the left side of the posting menu.
Put your sketch between the code tags [code][/code]
int LED_1 = 2;
int LED_2 = 3;
int LED_3 = 4;
int LED_4 = 5;
int LED_5 = 6;
int sensorPin1 = A1;
int sensorValue1 = 1;
int sensorPin2 = A2;
int sensorValue2 = 2;
long randomNumber;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("starting new random number sequence");
pinMode(LED_1, OUTPUT);
pinMode(LED_2, OUTPUT);
pinMode(LED_3, OUTPUT);
pinMode(LED_4, OUTPUT);
pinMode(LED_5, OUTPUT);
randomSeed( analogRead(A0));
}
void loop() {
// put your main code here, to run repeatedly:
randomNumber = random(2,7); //try 8 for additional lag