# Controlling strobe delay of two RGB LED strips

Hello, another programming noob here

I am working on a little halloween project where I want to independently adjust the strobe rate of two RGB LED strips with two pots. I have the circuit all figured out and breadboarded up. But where I am struggling is getting each strip to strobe at the value given of each pot. All I can seem to get them to do is get them to strobe the same rate. I am using code that I got from the web for motion delay. All I did was adjust the delay times to be longer and add in the additional pins I am using and a var for the second pot. Any help or direction is greatly appreciated.

the code is below. thanks again for any suggestions

``````int potentiometer_pin = 0;
int potentiometer_pin2 = 1;

int led_pinR = 10;
int led_pinG = 9;
int led_pinB = 11;
int led_pinR2 = 3;
int led_pinG2 = 5;
int led_pinB2 = 6;
int var = 0;
int var2 = 0;
// How much time should the light stay on between delay times (in Micro Seconds)?
/* Big number = more blur, more perceived brightness
* Small number = less blur, less perceived brightness  */
long on_time = 90000;
long on_time2 = 90000;
// How much should we multiply the incoming value by?
/* Big number = less precision, more range
* Small number = more precision, less range  */
long analog_value_multiplier = 50; // 15 Seems to work well for fast fans =)
long analog_value_multiplier2 = 50;

// What should the minimum delay be (in Micro Seconds)?
// This sets the bottom delay range of the strobe, as a delay of 0 doesn't actually flash =P
// The strobe starts with this is the "fastest" mode, and goes slower from there, adding to the delay
long minimum_delay = 90000; // 500 (half a millisecond) is a great superfast start
long minimum_delay2 = 90000;

// Initialize the number to hold our strobe delay. Isn't used till we get to the main loop
long strobe_delay = 0;
long strobe_delay2 = 0;

void setup()  { //VOID SETUP
// Tell the arduino to use the led_pin as an output.
pinMode(led_pinR, OUTPUT);
pinMode(led_pinG, OUTPUT);
pinMode(led_pinB, OUTPUT);
pinMode(led_pinR2, OUTPUT);
pinMode(led_pinG2, OUTPUT);
pinMode(led_pinB2, OUTPUT);

}
void loop() {
// Read the value from the potentiometer, and use it to make our strobe delay
// by adding the minimum delay, then increasing it to a useful value with analog_value_multiplier

strobe_delay = minimum_delay + analogRead(potentiometer_pin) * analog_value_multiplier;
strobe_delay2 = minimum_delay2 + analogRead(potentiometer_pin2) * analog_value_multiplier2;
digitalWrite(led_pinR, HIGH);
digitalWrite(led_pinR2, HIGH);
digitalWrite(led_pinG, HIGH);
digitalWrite(led_pinG2, LOW);
digitalWrite(led_pinB, LOW);
digitalWrite(led_pinB2, HIGH);
// Delay for the given on_time. (Limits Bluring)
delayMicroseconds(on_time);
delayMicroseconds(on_time2);
// Switch the led_pin to LOW. Turn off the led.
digitalWrite(led_pinR, LOW);
digitalWrite(led_pinR2, LOW);
digitalWrite(led_pinG, LOW);
digitalWrite(led_pinG2, LOW);
digitalWrite(led_pinB, LOW);
digitalWrite(led_pinB2, LOW);

// Delay for the strobe_delay time read from the potentiometer
// (less the time we already spent from leaving the LED on.)
// delayMicroseconds() fails beyond 16,000 uS, so pass it off to delay() after 10k
if (strobe_delay > 5000){
delay((strobe_delay - on_time) / 1000);
}else{
delayMicroseconds(strobe_delay - on_time);

if (strobe_delay2 > 5000){
delay((strobe_delay2 - on_time2) / 1000);
}else{
delayMicroseconds(strobe_delay2 - on_time2);
}

}
}
``````

The issue I see is I dont see any code what makes the two delays specific to a certain strip.

``````  delayMicroseconds(on_time);
delayMicroseconds(on_time2);
``````

Line 2 basically replaces the first (no strip is identified)

``````  if (strobe_delay > 5000){
delay((strobe_delay - on_time) / 1000);
}else{
delayMicroseconds(strobe_delay - on_time);

if (strobe_delay2 > 5000){
delay((strobe_delay2 - on_time2) / 1000);
}else{
delayMicroseconds(strobe_delay2 - on_time2);
}
``````

Again here, you set the proper numbers for the two different timings but the delay and delayMicroseconds functions doesnt specify which strip they apply to in the IF statements.

Need something along the lines of:

``````  strip1.delayMicroseconds(on_time);
strip2.delayMicroseconds(on_time2);
...
if (strobe_delay > 5000){
strip1.delay((strobe_delay - on_time) / 1000);
}else{
strip1.delayMicroseconds(strobe_delay - on_time);

if (strobe_delay2 > 5000){
strip2.delay((strobe_delay2 - on_time2) / 1000);
}else{
strip2.delayMicroseconds(strobe_delay2 - on_time2);
}
``````

That code will not be exact but I hope it helps clear what I believe to be the problem.