Page 1 of 1

Flashing/blinking LED

Posted: Mon Jul 16, 2007 5:30 pm
by echase
Is there a simple way of flashing a LED whilst carrying on with another task. A simple loop of turn LED on, delay, turn LED off, delay, will of course flash it, but can't then move on to perform other code.

Can I use a timer or something like that to flash the LED? Could use a very slow PWM but I don't have PWM on my version of Flowcode.

I want to do this to blink my LEDs briefly to save battery power.

Posted: Tue Jul 17, 2007 2:29 am
by Chet
Use a timer interrupt to make a counter. blink when counter = whatever
your delay needs are. Theres a little more to it but this is a start. :wink:

Posted: Tue Jul 17, 2007 11:37 am
by Benj
Here is a simple program.

Main Program
Start
Calculation - counter = 0
Interrupt - Enable timer interrupts
While 1 - Main Program Loop
End

Timer_Interrupt_Macro
Start
Decision - Counter = 255
YES: Decision - PIN on - YES - Turn Off Pin / NO - Turn On Pin
NO: Calculation - Counter = Counter + 1
End