Hi All,
Would sincerely appreciate some advice. I'm slowly teaching myself basic Arduino programming. For my latest project I'm combinging an 11 I/O Larson Scanner (LEDs) with a 4 I/O flickering LED setup. Both are sample code from others that I'm slowly using to help myself learn. Both work fine individually. The flicker has a random delay at the end of the loop which pauses the larson scanner. I was thinking I should look to replace the random delay with a random integer/counter. The idea would be I add a variable that counts 1 per rotation through the loop at at the random delay mark (50/150) executes the flicker. I'm digging around for sample code to do it, and just really wanted to ask if I was on the right track or if there was a better way to do it.
Here is the sample code that I am thinking would work within another loop if I changed the random delay to a random integer that counted per rotation:
int LED_Pin0 = 0; // Use Pin 0 for the LED. (Any PWM Pin will work for this.)
int howBright0; // Intensity of the LED: [0 = Off], [255 = Brightly Lit]
int LED_Pin1 = 1; // Use Pin 1 for the LED. (Any PWM Pin will work for this.)
int howBright1; // Intensity of the LED: [0 = Off], [255 = Brightly Lit]
int LED_Pin2 = 2; // Use Pin 2 for the LED. (Any PWM Pin will work for this.)
int howBright2; // Intensity of the LED: [0 = Off], [255 = Brightly Lit]
int LED_Pin3 = 3; // Use Pin 2 for the LED. (Any PWM Pin will work for this.)
int howBright3; // Intensity of the LED: [0 = Off], [255 = Brightly Lit]
void setup()
{
pinMode(LED_Pin0, OUTPUT);
pinMode(LED_Pin1, OUTPUT);
pinMode(LED_Pin2, OUTPUT);
pinMode(LED_Pin3, OUTPUT);
}
void loop()
{
howBright0 = random(128,255); // Change brightness to something between 128 and 255
howBright1 = random(128,255); // Change brightness to something between 128 and 255
howBright2 = random(128,255); // Change brightness to something between 128 and 255
howBright3 = random(125,255); // Change brightness to something between 128 and 255
analogWrite(LED_Pin0, howBright0); // Illuminate the LED with the brightness picked
analogWrite(LED_Pin1, howBright1); // Illuminate the LED with the brightness picked
analogWrite(LED_Pin2, howBright2); // Illuminate the LED with the brightness picked
analogWrite(LED_Pin3, howBright3); // Illuminate the LED with the brightness picked
delay(random(50,150)); // Makes LED seem to flicker when on for a random time
}