-->
Page 1 of 2

Flash an LED with timer

PostPosted: Wed Jun 08, 2016 9:19 am
by ardhuru
Guys, I have a code thats running satisfactorily. It does not use the timer.

Now, how would I blink an led in the background with an asymmetric duty cycle (on for 100ms every second) using the timer? I have seen examples where the led toggles symmetrically using the timer function, but I cant figure out how to modify that for asymmetric operation.

Another somewhat related query; the ESP8266 has 6 separate timers, right? Can ESP8266Basic use the others as well?

Regards.

Re: Flash an LED with timer

PostPosted: Wed Jun 08, 2016 7:15 pm
by russm
When the timer triggers (branches), turn on the LED, add a delay 100, turn off the LED, that completes the operation.

I think delay 100 would be 100ms...

Code: Select alltimer 1000, [blipLED]
wait

[blipLED]
io(po,16,1)
delay 100
io(po,16,0)
wait
end

Re: Flash an LED with timer

PostPosted: Thu Jun 09, 2016 11:02 am
by ardhuru
Thank you very much, that worked like a charm.

I have another question though; is there a way to avoid the delay in the branched sub? I might loose some data I receive on the UDP channel during that delay?

Can any of the other timers be used for this?

Re: Flash an LED with timer

PostPosted: Thu Jun 09, 2016 4:33 pm
by russm
I'm sure someone will correct me if I'm wrong but receiving data (unless using the software serial port) is via hardware and it will be serviced without data loss, even while the delay is running.