Celtic Kane

Introduction

Have you ever written a program that required your calculator to pause for a few seconds…but you couldn’t finish it because the calculator doesn’t have a delay function? If you’ve ever wanted to draw a picture of a face and have the eyes blink, or even make a complex game that required a time delay — this program is for you =) Even though I’ve listed this under the ‘products’ section, the code is so short I might as well just turn this into a tutorial as well.

Syntax

(time delay in seconds) -> A
pgrmDelay

The Actual Code

The program works by calling it while in a different program. Here’s the code that you should save as pgrmDelay:

:0->I
:A*65->A
:While A>=I
:I+1->I
:End

The Inner Workings of the Code

That seems pretty simple…but how does it work and what’s the significance of the number 65? Well, if you look carefully at the syntax for the program, you are supposed to set a value to A (the number of seconds you want to delay), then call pgrmDelay (the code above). So when we start out the code, we should already have variable A defined. Then we set I to 0, and have it increment all the way to whatever A equals. It’s as simple as that. Because TI graphing calculators aren’t exactly speed demons, it takes them a while to execute I+1->I and determine if A=I.

The Significance of 65

What about the 65? Well, this number is actually changeable based on the type of calculator you’re using. I tested my calculator on a TI-83 Plus, and it just so happens that my calculator can increment a variable by 1 65 times a second. If you aren’t using a TI-83 Plus, and you want to be more accurate with A being a delay of seconds, you can try to find your own value instead of 65… Make a program that increments a variable, set the incrementation in an infinite loop, and then grab a stopwatch. Let the program run for 30 seconds, then hit the ON button to break the loop. Record how high your incremented variable got, then repeat a few more times for accuracy. Take the average number that you get, divide by 30, and you should have the number of increments your calculator can do per second.