- Timer in Basic... Impossible?
- 05 Oct 2019 10:13:35 pm
- Last edited by Jcsq6 on 05 Oct 2019 10:51:39 pm; edited 11 times in total
I think a timer in Basic is feasible to be accurate within .05 seconds. This is my idea (some errors to be worked out but it gets the idea across)-
Code:
I've been yelled at a lot on SAX for this please give me your logical, well reasoned thoughts below. And feel free to ask any questions about the code
Code:
ClrHome
1→Q
0→T
0→A
0→O
0→P
0→U
0→S
0→D
Output(5,4,"PRESS ANY FOR START"
Repeat Ans //waits till button is pressed
getKey
End
ClrHome
Repeat not(C)+(startTmr=A)+getKey
O+(P-T→O //O is the offset between the start of a second of the RTC and where you pressed the button... in ticks
If Q=0
33-P→O //33 is the estimated ticks/ sec for times under one second
P→T
O
While (Ans>0)not(getKey // counts down offset
Ans-1
End
Ans→D
Q+(Ans=0→Q
U+P+(O-D→U
Output(5,13,Q
D=0→C
0
startTmr→A
While Cnot(getKey)(startTmr=A // waits till RTC changes and counts ticks till then
Ans+1
End
Ans→P
End
ClrHome
//calculate Seconds
Output(5,12,S
I've been yelled at a lot on SAX for this please give me your logical, well reasoned thoughts below. And feel free to ask any questions about the code