random LED turnon/turnoff/reset before new random blink begins - please help

Having trouble controlling LED series that blinks randomly.
I can make a series of leds blink randomly, but I cant get them to blink off before the next led lights up.
All I get is a series of new blinks while the LEDS are still on, then eventually they fade off, which means I have at one time 2, 3 and even 4 leds that are lit up at once time

what I am trying to do is have a series of LEDS randomly blink one at a time between 1 second intervals.
the LED should light up for half (.1/2) a second, then
LED turns off for (1/2) second then…
New random LED blinks for (1/2) second, then…
LED stays on for (1/2) second…
and loops for 60 seconds

Can anyone help modify what I got so far.
thanks to anyone thats kind enough to help


#define numberOfLEDs 10
long nextFlash[10];
int ledPin[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; 
int ledState[10];

void setup(){
for(int i = 0; i<numberOfLEDs; i++){
pinMode(ledPin*,OUTPUT);*
_ ledState *= LOW;*_
<em>_ digitalWrite(ledPin*, LOW);*_</em> 
<em><em>_ nextFlash *= millis() +random(100, 1000);*_</em></em>
<em><em>_*}*_</em></em> 
<em><em>_*}*_</em></em>
<em><em>_*void loop(){*_</em></em>
<em><em>_*for(int i = 0; i<numberOfLEDs; i++){*_</em></em>
<em><em><em>_if(millis() > nextFlash*){*_</em></em></em>
<em><em><em><em><em> if(ledState <em>== LOW) ledState _= HIGH; else ledState *= LOW;*_</em></em></em></em></em></em>
<em><em><em><em><em><em><em><em> digitalWrite(ledPin_,ledState*);*_</em></em></em></em></em></em></em></em>
<em><em><em><em><em><em><em><em><em>_ nextFlash *= millis()+random(100, 1000) ;*_</em></em></em></em></em></em></em></em></em> 
<em><em><em><em><em><em><em><em><em>_*} }*_</em></em></em></em></em></em></em></em></em>

Hi and welcome.

You are using the blink without delay example for your timer, which is the way to go. But you are forgetting about the consequences of that. You are running trough 18 possible LEDs ( numberOfLEDs == 18). These seem to be somehow connected to 10 pins. During your loop, you are setting each ledPin to some level. Then the next iteration starts, and you are doing all that again. The level you are setting can be another level as the one before, or the same. Your timer does do something, but i'm not sure that is what you want it to do.

One part of your problem is the for... loop. You got rid of some blocking code by using the blink without delay method. But you then added another blocking code to it, being the for... loop. Once you're in it, you won't get out unless you run all through it. That doesn't need to be a problem, but is is a trap you stepped in to. You can do what you're out to do without the for... loop. Remember the void loop() runs over and over again. So there is no need to create some other loop. you really need to keep track of what you are doing and what you have been doing. So now a bit towards the solution.

Pick a LED that you want to control. Set the timer to a random value. Now keep handling that LED until you are through with it, this is the part you forgot. So switch it on at the right time, set another time to switch it off again. Then go on to the next LED.

You need some variables that tell you what state you are in, and what state you will be in next. Also you need to count the LEDs, if you reached your total number of LEDs, you need to reset that counter to the first LED.

I hope you will be able to go on with this information. In case you hoped to find some improved code, i won't do that.

Mas3 - appreciate the reply.
I know what Im trying to do I just dont know the commands, no where in the books I am trying to read or in the sketches Im finding does it tell me exactly how to do anything you say - so its all greek to me.
If there was one sketch that did maybe 2 or even 1 LEDS then I could decipher it that way…but there doesnt seem to be anything out there that does it in the specific way I need to - so how can I learn the concept if it hasnt been done?

Anyone else have any links or tips they think that could help.
Please keep in mind Im very new at this, .
Greatly appreciated

so how can I learn the concept if it hasnt been done?

You work it out. That is what I had to do in the 1970s before the internet and any books on the subject. Anyway it has been done many times.

I know what Im trying to do

But you fail to communicate it correctly with others.

I just dont know the commands

They are digitalWrite, if and = What you need to do is to put them in the right order.

Totally untested but is in the right ball park:-

void loop(){
static int i=0, falshesPerLED = 0;
if(millis() > nextFlash){
  if(ledState == LOW) ledState = HIGH; else ledState = LOW;
  digitalWrite(ledPin[i] ,ledState);
  nextFlash = millis()+random(100, 1000) ;
 flashesPerLED ++;
} 
if (flashesPerLED > someNumber) {
 flashesPerLED = 0;
 i++;
if( i >= numberOfLEDs) i=0;
}

Hi.

I'll be happy to help you out with anything i can. But i will not do the work for you. Just now, you indicated you would like to learn, i have respect for that and will support it.

So here are some tips that have been reported to be helpful in the past.

1st of all, take very small steps. Do not try to solve all your problems in one go. Try to break your problems down to smaller (sub)problems, which will probably easier to solve.

In this case, i would have had the blink without delay sketch changed so that there would be 2 LEDs blinking alternatively. This will already solve one of your problems. Then have them blink with random intervals. Once you have that, you can expand the number of LEDs.

More tips: If you get into trouble and would like to get some help, this forum is great for that. But do not assume that everyone already knows what you have been doing (like trying to find information in books and such). Try to give as much information in your questions, it will help in giving suiting answers.