Go Down

### Topic: Simulate a welding arc light (Read 3194 times)previous topic - next topic

#### airmale ##### Oct 25, 2011, 05:59 am
I'm a newbie. how do I blink the two leds at varying rates each separately. I can setup one led to blink on and off using delay but how do I do the same with 2 leds. I would like to have at least 10 high and 10 low with 10  different values of time for each one of the 10 high and ten low. 10 high and 10 low for each led.
This one i found just blinks each led at different rates is there a way to accomplish my goal with this sketch?

/* Blink Multiple LEDs without Delay
*
* Turns on and off several light emitting diode(LED) connected to a digital
* pin, without using the delay() function.  This means that other code
* can run at the same time without being interrupted by the LED code.
*/
int led1 = 3;                // LED connected to digital pin 13
int led2 = 5;
int value1 = LOW;                // previous value of the LED
int value2 = LOW;                // previous value of the LED
long time1 = millis();
long time2 = millis();

long interval1 = 45;           // interval at which to blink (milliseconds)
long interval2 = 33;

void setup()
{
pinMode(led1, OUTPUT);      // sets the digital pin as output
pinMode(led2, OUTPUT);
}

void loop()
{
unsigned long m = millis();

if (m - time1 > interval1){
time1 = m;

if (value1 == LOW)
value1 = HIGH;
else
value1 = LOW;

digitalWrite(led1, value1);
}

if (m - time2 > interval2){
time2 = m;

if (value2 == LOW)
value2 = HIGH;
else
value2 = LOW;

digitalWrite(led2, value2);
}
}
any help would be greatly be appreciated
THanks 