I'm very new at this and I've been reading but can't really find the answer,
It seems it would be very simple I just need a little help
I'm writing some code for a lightning simulator , I'm using delay to create some random flashing with more and less intensity on each flash, it's working pretty well but I can't seem to figure out how to turn on 3 leds at the same time (that are each assigned to their own pin output).I'm using delay on every function so I know that holds everything up but is there a way to write it into the sketch to just turn them all on and off again, I don't want to set it on a timer using blink without delay id rather just write it into my code to turn all 3 leds on a few times until it restarts

I don't quite follow what you want to do here. You just want to turn three leds on? Just do three digitalWrite commands back to back. If you want them to be on for some certain length of time then you'll have to either have a delay call or use the blink without delay paradigm. If you just write them high and then immediately low it will happen so fast you can't see it.

Something like this?

``````#define ARRAYELEMENTS(x)  (sizeof(x) / sizeof(x[0]))

#define MINDELAY    1     // Time between strikes
#define MAXDELAY    6

#define BUILDDELAY   100  // Small delay to build lightning

int LEDs[3] = {10, 11, 12};  // LEDs on these pins?
long rand;

void setup() {
int i;
// put your setup code here, to run once:
randomSeed(A0);
for (i = 0; i < ARRAYELEMENTS(LEDs); i++) {
pinMode(LEDs[i], OUTPUT);
}
}

void loop() {
rand = random(MIDNDELAY, MAXDELAY);
delay(rand * 1000);  // This much time between strikes. Change to
// use millis()...same for others
DoLightning();
}

void DoLightning()
{
digitWrite(LEDs[0], HIGH);
delay(BUILDDELAY);        // Make lightning build rather than all at once
digitWrite(LEDs[1], HIGH);
delay(BUILDDELAY);
digitWrite(LEDs[2], HIGH);
delay(BUILDDELAY * 3);
digitWrite(LEDs[0], LOW);
digitWrite(LEDs[1], LOW);
digitWrite(LEDs[2], LOW);
}
``````

You can figure out what this does and then get rid of the delay() calls.

You could use PWM to ramp up the brightness of each led even.

The demo several things at a time is an extended example of the BWoD technique.

...R