The Entertainment Shack


TI-83 Plus / TI-84 Plus Programming Basics

Posted by Erik W on Jan 12, 2003 5:43 PM

I have been programming calculators for quite some time, so I wanted to share some of my knowledge. Here is a simple TI-83+ BASIC programming tutorial (will also work on new TI-84+ series) with basics on input/output, looping, and conditions.

Lesson 1, The Basics

Before you can dive into programming, you have to learn a little about how the calculator works.

Making a new program


newIt is simple to make a new program. From any section on the TI calculator, press the [PRGM] button. Then press the right arrow twice so NEW is selected. It should look like the image to the right:
nameprgmscreenHit [ENTER] and type in a name for the program. You will see the calculator limits the name to 8 letters (left) so pick a name carefully. Hit [ENTER] again and you will get to the screen where you can enter the BASIC code (right), which you will learn later.

Exiting


Say you're done programming, either sick of it or you want to do something else, just press [2nd] then [MODE] (quit). You'll end up at the main screen where you can add, subtract, etc like normal.

Saving


You spent all that work making CHECKERS, and you want to save don't you? Well it's automatic. The moment you hit a key, its recorded into memory. That's good right? Yes, until you hit the [CLEAR] button and find out you deleted a line it took weeks to enter in. Which brings me to my second point -- there is no "Edit Undo" key, sorry.

Editing


editTo edit a program, from any screen, hit the [PRGM] button, then the right arrow once so EDIT is selected. Then use the up and down arrows to select the program you wish to edit. Hit [ENTER] and you'll be brought to the programming screen.

Running


runTo run a program, from any screen, hit the [PRGM] button, then use the up and down arrow keys to select the program. Hit [ENTER] twice and the program will run.

Deleting


To delete a program, press [2nd] then [+] (mem). On the memory screen, hit [2] then [7]. Go to the program you want to hit and press the [DEL] key. It will ask you if you're sure, hit [2], and it's gone! [PLEASE NOTE: These instructions will be slightly different for the TI-83 regular]
deleting deleting deleting deleting


FAQ


Q. Hey! How come there are asterisks (*) in your program names, but when I try it won't let me!
A. Those aren't part of the program, they are telling me that the programs are in the archive memory. (refer to section 18-10 in your manual) Also, its a TI-83 Plus thing only.

Q. How do I lock my programs so they can't be edited?
A. See this tutorial.

Application


guessnumThroughout the tutorials, we will be creating a Guess the Number game using information from the lesson you just read. Start by creating a new program called "GUESSNUM".


Lesson 2, Math & Variables


About Variables


The first thing you need to know is variables, and how they work. A variable is something, usually a letter, that stands for something else. That's nice, so how to you use them?

Storing Variables


storeFirst go to the main screen by pressing [2nd] and [MODE] (quit). Then, to store a number as a variable you enter the number, then you press the [STO->] button, and then [ALPHA] and the letter you wish to store the number as. Hit [ENTER], and the number will display again showing a successful stored variable. (left)

Recalling Variables


recallMake sure you're at the main screen by pressing [2nd] and [MODE] (quit). Then, to recall a variable, simply press [ALPHA], the letter, and hit [ENTER]. (right)

Math with Variables


mathThe nice things about variables, is if you need a number in an equation a lot, you just store the number as a variable, and use the variable in place of the number. FOR EXAMPLE: You were given the equation Y2+4Y-9, and your teacher wants you to plug in 629 for Y. All you would do is press [6][2][9] then [STO->] then [ALPHA] and [1](Y) then [ENTER] to store the variable. Once you did that, just plug in the equation and hit enter! ([ALPHA] [1](Y) [X2] [+] [4] [ALPHA] [1](Y) [-] [9] [ENTER])

Programming


Ahh finally, you get to start programming. Go ahead and make a new program called MATH. (you learned how to do this last lesson!) You're going to use this for the next couple of lessons.
programmingEvery day in class, your teacher has you plug a different number into Y2+4Y-9 and you're just SICK of typing it in every day. Well, you can make a program for it! Go and edit the MATH program you just created. It should be blank. On the first line, type the equation above ([ALPHA] [1](Y) [X2] [+] [4] [ALPHA] [1](Y) [-] [9] [ENTER]) You're not done however, you need to tell the calculator some place to put the answer. Let's store it as "A", so after the equation press [STO->] and [ALPHA] [MATH](A). You have one more thing to do, which is tell the calculator to end the program. So hit [ENTER] for a new line, then hit the [PRGM] button, and scroll down way to the bottom until you come to the "Stop" command. Hit [ENTER] to add that command. Your program should look like the one to the right.
matthprogSo you have the program, now how to you use it? Press [2nd] and [MODE](QUIT) to get to the main screen. Today's number is 57 so store that as "Y". Next, run the program. It will do the math and display "Done". Finally, to see the answer it came up with, recall the variable "A", which is the variable you specified in the program to store the answer as. Your screen should look like the picture to the left.


FAQ


none yet


Application


guessnumEdit the GUESSNUM program you created last lesson. We're going to create a random number between 1 and 50, so on the first line of your program, push [MATH] then press the right arrow three times so PRB is selected. Next, press [5] to select the random integer command. Press [1] then [,] and [5][0]. End the command with the [)] key, and finally store it as the variable "A" by pressing [STO->] then [ALPHA] and [MATH](A).


Lesson 3, Displaying Stuff


Wouldn't it be nice if the math program we created last lesson could display the answer for us? Well it can! I'll show you some methods of displaying text, then we will apply it to the math program. For now, make a blank program so you can try the commands below.

The DISP Command- Text


Inside a program on a blank line, press [PRGM] then the right arrow to get to the I/O screen, and [3] for the DISP command. Now, to display text, you need to surround it with quotes. So go ahead and press [ALPHA] [+]("). Then type something like HELLO, and end it with a quote. Go to the main screen and run the program. This whole process is illustrated below.
disp1 disp2 disp3

The DISP Command- Variables


disp4Hmm.. so how do you display values of variables? Just press [PRGM] then the right arrow to get to the I/O screen, and [3] for the DISP command. Then simply press [ALPHA] and the variable you wish to display the value of.

The OUTPUT Command


To get more control out of where the text displays, there is the OUTPUT command. It is in the format of Output(row [1 through 8],column [1 through 16],text or variable). Go ahead and open up your test program. Press [PRGM], go over to I/O, and press [6]. We'll display the word "HI" in the middle of the screen, so press [5] then [,] then [7] then [,] then type in "HI" and end the command with [)]. Exit the programming screen and run the program. Hmm.. well it's not exactly center but you get the idea.
disp1 disp2 disp3

Our MATH program


mathmathIf you remember, last lesson we made a math program which required us to manually type in "A" to see what the result was. Using the DISP command, we'll make it say "THE ANSWER" then display the value of A. Open the MATH program and go to the line with Stop on it. Press [2nd] [DEL] (ins) then [ENTER] to insert a new line between the two. Go up to the line and press [PRGM], go to the I/O menu, and hit [3]. Next, type "ANSWER" followed by [,] and then the letter A by pressing [ALPHA] [MATH] (A). It should look like the image to the left. Exit and run the program, using 100 for Y. It should look like the image to the right.

FAQ


Q. Hmm.. how come in the math program you had me put the STOP command at the end, and in the examples you don't?
A. The STOP command is actually optional, but it is a good habit to get into. I was just too lazy to do that in these examples.

Q. How can I clear the screen in the program?
A. To clear the home screen, use the ClrHome command by pressing the [PRGM] button, going to the I/O menu, and pressing [8].

Application


guessnumEdit the GUESSNUM program. We're going to tell the person that they have to pick a number between 1 and 50. Hit enter to create a new line in the program, and then hit the [PRGM] button, press the right arrow button once so I/O is selected, then press [3]. Press [2nd] [ALPHA] for an alpha lock, then type in "PICK A NUMBER","FROM 1 TO 50". (you will need to take off the alpha lock for the numbers by pressing [ALPHA])


Lesson 4, Inputting


Now.. Wouldn't it be nice if the math program we created could also prompt us for "Y" instead of have us manually store something as it? Well it can! I'll show you some methods of inputting data, then we will apply it to the math program. For now, make a blank program so you can try the commands below.

The INPUT Command


inputinputInside a program on a blank line, press [PRGM] then the right arrow to get to the I/O screen, and [1] for the INPUT command. Next, press [ALPHA] then the variable you want to store the inputted data to. When run, a question mark will appear waiting for you to enter a number. Enter the number, and it will be stored as the variable you specified.

The PROMPT Command


inputinputThe PROMPT command is an alternate way to input data, but is slightly different which you will see in a second. Inside a program on a blank line, press [PRGM] then the right arrow to get to the I/O screen, and [2] for the PROMPT command. Next, press [ALPHA] then the variable you want to store the inputted data to. Now, When run, a question mark will appear waiting for you to enter a number. In front of the question mark, unlike the INPUT command, it tells what variable it is storing the inputted data to.

The MATH Program


mathmathBack to the math program, you now know how to make it ask you for Y instead of manually entering it. Go ahead and open the math program. On the first line press [2nd] [DEL] (INS) and [ENTER] to create a new line. Then press the [PRGM] button, go to the I/O menu, and press [2]. Next, press [ALPHA] then [1] (Y). Exit, and run the program. Cool huh.


FAQ


mathQ. How come I get an error when I try to input text?
A. Text can't be stored using the letter variables (A-Z), they have their own separate variables. To get to them, press [VARS] then [7] and select a string from 0 to 9.

Q. Can I make the input cursor appear anywhere on the screen?
A. Nope


Application


guessnumEdit the GUESSNUM program. Now it's time to get the person's guess. Go to the last line of the GUESSNUM program and hit [ENTER]. Press [PRGM] then go to the I/O menu, and press [1]. Next, press [ALPHA] then [APPS] (B).


Lesson 5, IF Statements


Every TI programmer should know how to do is to properly use "IF" statements to compare two or more values, and there are three ways to do this.

IF Statement


the codeexample 1
example 2The most simple way to compare something is the IF statement. How it works, is if the IF statement is true, it runs what is on the next line, otherwise it skips it. We'll make a simple program to check if your name is "Erik" or not. First prompt for someone to enter your name (remember you have to store text as a string). Then to get the IF command, when inside a program, press [PRGM] then [1]. Following the IF statement we want to put Str1, which is what the user entered their information as, so press [VARS] [7] [1]. Next, to get the symbols to compare, press [2nd]+[MATH](TEST) then press [1] for the equal sign. Next type "Erik" with the quotes. In the next line, we'll display "ERIK!!!" to show our happiness of greeting him. Following that line, we'll display a simple "Hi" which will show to you if your name is or isn't Erik.

IF-THEN Statement


the codeexample 1
example 2The IF statement is fine, unless you want to do more than one thing if something is true. That's where the IF-THEN statement comes in. The way it works, is following the IF statement, instead of the command you wish to run, you put THEN ([PRGM] [2]), then the commands, followed by END ([PRGM] [7]) to tell the calculator that is the end of all the commands you want to do if the IF statement is true. So let's modify the above program to stop if the name entered is "Erik", so the generic "Hi" isn't displayed. So open up the program you made above, and move the cursor to the line that says DISP "ERIK!!!" and press [2nd] [DEL](INS) then [ENTER] to insert a new line. Then press the up arrow to get to that line, and press [PRGM] [2] to get the THEN statement. Then scroll down to the DISP "HI" line and insert two blank lines. In the first blank line, put a stop there to end the program by doing [PRGM] [ALPHA] [COS](F). The on the next line do [PRGM] [7]. The code should look like the code to the left. Now if we run the program, and enter "ERIK" as the name, the program displays "ERIK!!!" and stops before the generic "HI" is displayed. (See the images on the right).

IF-THEN-ELSE Statement


the codeexample 1
example 2The above program is fine, unless we don't want to stop the program when someone entered "Erik" and we still don't want to display the generic "HI" when another name is entered. This calls for the IF-THEN-ELSE statement. If something is true, it runs the commands between the IF and ELSE statement, and if it is false, it displays the commands between the ELSE and END statement, and then continues to run after the END statement. Modify the program to look like the code to the left to fix up our program. (To get the ELSE command, you press [PRGM] [3])

Comparing More Than Two Things


the codeWe're almost done. There is one more thing you might want to do, and that is to compare more than two things. For example, maybe you want to see if Str1 is equal to "ERIK" or "KEVIN". To do that, you will be using the OR statement. Open back up your NAME program, and move your cursor to the end of the If Str1="ERIK" line. Then press [2nd]+[MATH](TEST), Press the [->] button to go to the LOGIC menu, then press [2] for OR. Notice there is also AND if your IF statement were to require you to use that. Then after the word OR, press [VARS] [7] [1] for Str1 again, [2nd]+[MATH](TEST) then [1] for the equal sign, and then type "KEVIN". Then you might also want to change Disp "ERIK!!!" to something else since that will display if the name is either ERIK or KEVIN.
example 2example 2example 3

FAQ


none


Application


guessnumNow, since you know IF statements, we're going to add a few to check if the person got it exactly, was too high, or too low. We're going to put IF statements inside an IF-THEN-ELSE statement, going something like this: IF the number was correct, THEN tell them that they were and stop the program, ELSE see IF they were too high and tell them, or see IF they were too low, and tell them. Then we'll END the IF-THEN-ELSE statement as required.
So, open your guess the game program and go to the last line. Press [ENTER] for a new line. Press [PRGM] and [1] for the IF statement. Then press [ALPHA] [MATH](A), press [2nd] [MATH](TEST) and [1] for the equal sign, and then [ALPHA] [APPS](B). Then press [ENTER] for a new line, and press [PRGM] [2] for a THEN statement. Press [ENTER] again for another new line, and press [PRGM] [->] for the I/O menu, and [3] for the DISP command. In quotes then type "CORRECT". Press [ENTER] once again for a new line, and press [PRGM] [ALPHA] [COS](F) for the STOP command to end the program since they got it correct. Next, press [ENTER] for a new line again, and [PRGM] [3] for the ELSE statement. Press [ENTER] once again, and [PRGM] [1] for another IF statement and [ALPHA] [MATH](A), press [2nd] [MATH](TEST) and [3] for a greater than sign, and then [ALPHA] [APPS](B). Then press [ENTER] for a new line, and press [PRGM] [->] [3] for the DISP command and type "TOO LOW". Press [ENTER] once again, and [PRGM] [1] for another IF statement and [ALPHA] [MATH](A), press [2nd] [MATH](TEST) and [5] for a less than sign, and then [ALPHA] [APPS](B). Then press [ENTER] for a new line, and press [PRGM] [->] [3] for the DISP command and type "TOO HIGH". Finally press [ENTER] and then [PRGM] [7] to END the IF-THEN-ELSE statement we started.
Now if you run this program, you'll notice that it ends after it tells you if you're too high or too low, not allowing you to guess again. Go on to the next lesson to learn about GOTO statements and LABELS.


Lesson 6, Labels and Gotos


A final important programming thing to know is Labels and Gotos, which is quite simple. There are two commands involved, LBL, which marks certain spots in the program, and GOTO, which tells the calculator to go to a certain label.

The LBL Command


the codeThe LBL command marks places in the program you can GOTO. Create a new program, and press [PRGM] [9] for the LBL command. Then after the command, you can either have two letters, two numbers, or a number and a letter. Let's use A1 for the sake of this example, so on the same line, press [ALPHA] [MATH](A) then the number [1].

The GOTO Command


the codeexampleBefore we learn the GOTO command, in the program above, have the user input a number as A, then check if that number is 5 and if it is, stop the program. Now, if the person is trying to guess a number like 5 or something, instead of re-running the program over and over, if the program didn't stop, you can make it goto the first line to run again. On the last line of the program, press [PRGM] [0] then type A1, which is the name of the label you made earlier. Now when you run the program, it keeps running until you type 5.

FAQ


Q. The program is running in an endless loop!! What do I do?!?
A. Just press the [ON] button then [1] to quit.


Application


the codeexampleThis is the last step in our Guess the Number program. Put the cursor in front of the line that says Input B and press [2nd] [DEL](INS) and [ENTER] to insert a new line. Then in that new line, press [PRGM] [9] and [ALPHA] [MATH](A). Then go to the way end of the program, press [ENTER], and press [PRGM] [0] and [ALPHA] [MATH](A). Now go ahead and try your program!

listed in: ti calculators, tutorial


Comments


This is an okay site, but i would appreciate it more if u explained like what everything means in the catelog in the calculator, but i REALLY APPRECIATE the strng thing, ive wanted to make a program for chemistry where i jsut have to input the element symbol and it would give me info for it. THNX A LOT FOR THAT!!!!!!

Posted by Anonymous on January 1, 2005 10:39 PM


Webmaster's Response: Everything in the catalog is described in the back of the TI-83+ Manual. If you lost yours, it can be downloaded at the TI website.

Posted by Erik on January 1, 2005 10:41 PM


How can I get a cursor to set anywhere in the screen I want to?

Posted by Sainath on March 16, 2005 10:53 PM


Webmaster's Response: Are you asking for things like text input? No, you can't.

Posted by Erik on March 16, 2005 10:53 PM


Can you add comments to TI 83+ BASIC programs? If so how? Thanks

Posted by Anonymous on June 3, 2005 10:57 PM


Webmaster's Response: Yes you can. A string surrounded by quotation marks on its own line is ignored by the calculator when the program is run.
Example:
:Disp "HI"
:"THIS IS IGNORED"
:Disp "ABCD"

Posted by Erik on June 3, 2005 10:59 PM


I noticed that if you write a program that has two answers, such as the square root of a positive number, it only returns one answer. Do you know a way to solve this?

Posted by T on July 20, 2005 11:00 PM


Webmaster's Response: The calculator doesn't do this automaticly for you. You'll have to do something like this:

:Disp "ENTER NUMBER"
:Input X
:Disp "SQUARE ROOT:"
:If X>0
:Then
:Disp √(X)
:Disp -√(X)
:Else
:Disp "IMAGINARY NUMBER"
:End

Posted by Erik on July 20, 2005 11:01 PM


is there any way to get more than 0-9 and a-z?

Posted by ~boo~ on January 19, 2006 11:06 PM


Webmaster's Response: The TI 83+ Language Localization App gives you the opportunity to use foreign characters.

Posted by Erik on January 19, 2006 11:06 PM


Are there any programs you can make yourslef with out linking to a computer? I need the coding for any interesting or cool programs.

Posted by Jarade Springer on February 13, 2006 11:08 PM


Webmaster's Response: You can view the code for any of the BASIC programs, say on TI Calc using the Graph Link software, then type it manually in your calculator.

Posted by Erik on February 13, 2006 11:09 PM


I am an intermediate programmer for the TI-84. But I am having trouble making a program that disables people from editing your program that you made.

Posted by Collin Cerbus on April 25, 2006 6:21 PM


Webmaster's Response: I'm not sure, but I'll let you know if I figure it out. If anyone knows feel free to reply.

Posted by Erik on April 25, 2006 9:41 PM


Erik,
Thanks for the Programming Basics lessons.
I'd like to share a couple hardcopies with fellow students. Do you have a version that will print without all the "Google"dy-gook? and won't split screen dumps over page breaks?

Thanks Again,
Ren

Posted by Ren on April 5, 2007 10:09 AM


Erik,
A suggestion...

If you get around to writing another programming lesson for the TI calcs, could you include the FOR(,,,) loop and the WHILE(condition) and
REPEAT(condition) commands?

I have them penciled in the margin of my original hardcopy of your webpages.

Sincerely,
Ren

Posted by Ren on April 5, 2007 10:16 AM


Thanks for your comments. For a better print out, you can try by just selecting the main content starting at the title, and using Internet Explorer. It doesn't appear to split images between pages like Firefox does.

As for a more "advanced" tutorial... we'll see how much time I get. It's started, I just need time to finish.

Posted by Erik on April 5, 2007 4:01 PM


My son's TI-83 has frozen. He changed the batteries the other night and when he turned it back on it was just a blank black screen. It was definitely on because the black dots were on the screen. How do we fix this. He needs it for the last month of school (and then never again!!)

Posted by Glenda on April 24, 2007 7:07 PM


There are two ways you can do a hard reset of your calculator.
- First try leaving out the main and backup batteries for 3 hours before you re-insert them.
- If that doesn't work, take out one AAA battery, and hold down the [del] key when you reinsert it. Ignore the message on the screen. Re-remove one AAA battery, and without holding down any keys reinsert it. If the message on the screen says "Waiting...Please install calculator software now" you will need to re-install the TI Operating System using the TI-Connect Software and link cable.

Posted by Erik on April 24, 2007 8:28 PM


Can someone tell me what im doing wrong? Im trying to make a Hang-Man game and i do good with the first time i ask someone to put in a number that represents a letter (a=1 ect.) But when I do it again, the output that corresponds with what they put in the first time dissapears. How can I make it remember what they put in or how can I make it stay displayed? Also is it able to clear the screen without clearing their imput? Ive tried everything I could think of. Thanks for the help.

Posted by Scott on May 28, 2007 11:53 AM


Scott- I would suggest adding each input to a string (See FAQ under lesson 4), then re-printing that string using OUTPUT each time a new letter is entered.

Posted by Erik W on November 6, 2007 8:21 PM

 

Additional comments are no longer being accepted for this post.

Trackbacks are disabled on this post.