View Full Version : Timer Application
charudatt
- 15th September 2003, 15:13
Hello Once again,
I have a small application involving a Timer operation in which , on a press of a button , I have three LEDs that glow, The first LED switches off after 7 seconds, second LED switches off after 10 seconds and finally the third Switches OFF after 12 Seconds. The Duration of LEDs would change depending on different application.
I am interested in doing this with the On Board Timer and PIC Basic Pro Compiler.
Can anybody help me.
Thank you.
electronicsuk
- 20th September 2003, 11:46
You could quite easily use PAUSE and a FOR/NEXT loop, assuming you have other tasks to process as well as working the LED's.
Matthew
Darrel Taylor
- 7th February 2004, 08:21
This can be accomplished quite easily with the "Elapsed Timer Demo" found at http://www.picbasic.co.uk/forum/showthread.php?s=&threadid=190
In fact, you can do a lot of other things with it too. Since this thread is getting so many "Views" I assume that's what most people are really looking for.
Darrel
charudatt
- 7th February 2004, 14:17
Thank you Darrel. I shall surely go thru it and get back to you.
Dwayne
- 16th February 2004, 06:05
Hello Charudatt,
Your program can use this example as a base,
It could look something like the following:
LED1 var GPIO.0 ; Or whatever pin works on your chip.
LED2 var GPIO.1
LED3 var GPIO.2
FirstLed var byte
SecondLed var byte
ThirdLed var byte
counter var byte
Loop:
;Here your source gives you the values of the LED's length of time to stay on....
FirstLed=7 ;these values you get from your source
SecondLed=10
ThirdLed=12
; Lets turn them all on!!!
High LED1
High LED2
High LED3
counter=FirstLed*1000
Pause(counter);
Low LED1;
counter=(SecondLed-FirstLed*1000)
Pause(counter);
Low LED2;
counter=ThirdLed-SecondLed*1000);
Pause(counter);
Low LED3;
Goto Loop
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.