Go Down

### Topic: An LED flash question! (Read 599 times)previous topic - next topic

#### nicc

##### Dec 31, 2012, 08:32 am
How do I flash an LED on for 100ms and off for 3000ms without using delay?

#### marco_c

#1
##### Dec 31, 2012, 09:03 am
Look at the blink without delay example.
Arduino Libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com
Arduino++ blog https://arduinoplusplus.wordpress.com

#### JimboZA

#2
##### Dec 31, 2012, 09:11 am

Look at the blink without delay example.

But you'll need to think about how to have two different intervals for on = 100ms and off = 3000ms. As that example stands, the led is off and on for the same interval...
Johannesburg hams call me: ZS6JMB on Highveld rep 145.7875 (-600 & 88.5 tone)

#### nicc

#3
##### Dec 31, 2012, 03:59 pm
Could someone point me in the right direction. I have uploaded the blink without delay, but cannot see how to get the 'short on' and 'long off'

#### tack

#4
##### Dec 31, 2012, 04:10 pm
You'll need to keep two delays, timers and a state record

E.g.

2) While stateBlinkOn is true then you want to check timerBlinkOn each loop until it's equal or greater than millis() + delayBlinkOn.
3) Once the condition is met, turn your LED off and set stateBlinkOff to True and timerBlinkOff to current millis().
4) While stateBlinkOff is true then check the timerBlinkOff each loop until it's equal or greater than millis() +  delayBlinkOff.
5) Once the condition is met, you're back to turn your LED on at Step 1 above and the sequence repeats.

Now, go code that up. ;-)

#### AWOL

#5
##### Dec 31, 2012, 04:49 pm
All you need to do in the blink without delay is change the value of "interval" when you change the LED state.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up

Please enter a valid email to subscribe