I want to program a clock any ideas how i begin?
This is how I was coding
Loop while 1 Declared Variables - Seconds, Minutes, Hours
Calculation = Seconds=Seconds+1
Call Macro Start
Call Macro Clear
Cursor (6,0)
Call Macro Print (Seconds)
Decision Seconds=>59?
IF yes
Calculation Minute = Minute +1
Call Macro Start
Call Macro Cursor (4,0)
Macro Number Print " Minute"
Decision if Minute=>59?
Calculation = Minute = 1, Hour = Hour + 1
Decision if Hour =>12
calculation Hour=1
Am I doing it Wrong?? Can anybody give me any idea on how to do this and how to make inputs. This is my 3rd day with flow code. and am trying to program this clock, which is my first.
How Can I program a Clock in Flow Code?
-
- Posts: 110
- Joined: Thu Sep 29, 2005 10:53 am
- Location: Matrix Multimedia
- Been thanked: 1 time
- Contact:
The PIC already has a 'clock'.
The TMR0 Timer interrupt triggers at a rate of T times a second e.g 133Hz = 133 times a second. When ever it triggers it runs the code in the timer overflow macro.
By adjusting the pre-scaler value you can adjust the value of T that is convenient e.g. 75Hz rather than 128.5Hz.
Once you have that you can simply count to T and know that a second has passed.
then 60 seconds = 1 minute, 60 minutes.... etc.
The timer intterupt works in the background updating the clock variables - T, seconds, minutes etc. and the main program simply displays them.
The TMR0 Timer interrupt triggers at a rate of T times a second e.g 133Hz = 133 times a second. When ever it triggers it runs the code in the timer overflow macro.
By adjusting the pre-scaler value you can adjust the value of T that is convenient e.g. 75Hz rather than 128.5Hz.
Once you have that you can simply count to T and know that a second has passed.
then 60 seconds = 1 minute, 60 minutes.... etc.
The timer intterupt works in the background updating the clock variables - T, seconds, minutes etc. and the main program simply displays them.