TI-BASIC:Timers

From Learn @ Cemetech
Jump to navigationJump to search


Routine Summary

Calculates amount of time that passes.

Inputs


Outputs

Ans

Variables Used

T, M

Calculator Compatibility

TI-84/+/SE Author

Timothy Foster Download

No download provided.

:Pause "Timer Ready
:startTmr→T
:Repeat getKey
:Output(4,8,checkTmr(T
:End
:ClrHome
:checkTmr(T→T
:iPart(Ans/60→M
:T-60Ans→T
:{M,Ans

This simple routine counts up from when you press Template:Enter and stops when you press any button. This program calculates the amount of time that passes between key presses in minutes, and it displays the passing time in seconds as it is counting.

First, the clock makes sure you are ready to start the timer; it awaits you to press enter. Immediately afterward, the StartTmr command is activated into the variable T. CheckTmr(T tells how many seconds from the startTmr activation has gone by. When a key is pressed, a small calculation is performed to determined to find how many minutes have gone by.

This program is a basic example of how startTmr and checkTmr( can be used to count time. Unfortunately, this only works for the TI-84 series that have time compatibility.



Routine Summary

Counts down from a given time.

Inputs

M, S

Outputs


Variables Used

T, M, S, A

Calculator Compatibility

TI-84/+/SE Author

Timothy Foster Download

No download provided.

:Disp "Minutes?
:Input M
:Disp "Seconds?
:Input S
:60M+S→S
:Pause "Timer Ready
:ClrHome
:startTmr→T
:Repeat getKey or S=checkTmr(T
:For(A,1,6
:Output(4,8,S-checkTmr(T
:End
:Output(4,8,"____ //Four spaces
:End

This timer, instead of counting up, counts down from a given starting point. First, the program asks for minutes and seconds. Unfortunately, the checkTmr( command deals with seconds, so we must convert the minutes to seconds in order to make the program work better. According to the code, the timer will stop when either a key is pressed or the amount of time that passed is equal to the given amount of seconds.

The tricky part of the program is the use of as For( to display seconds remaining. The amount of seconds remaining is outputted at coordinate (4,8). So, the number is shown at the screen's center. However, when it goes from 100 to 99, the end 0 from the 100 still shows making it look like 990. To negate this, we use Template:Output(4,8,"'''''' or four spaces. This gets rid of the 0 making it output 99. Without the For( as a delay, the output would be invisible.