Intro: Programming a Texas Instruments Calculator
I am a high school student, and am required to have a graphing calculator for some of my classes. Most people have a Texas instruments calculator, usually a TI 83 or TI 84. I have noticed that few people know how to do much with their calculator. One of the most versatile and useful features of one of these calculators is its ability to be programmed. There are many websites that have programs ready for download, or have the code listed to be copied. Although these work, it isn't hard to learn to program the calculator yourself, and it is a useful skill.
I will explain step by step how to write a program that will do the quadratic formula. This is how I became familiar with programming and got used to the commands. I will then explain the theory behind several other programs (like games!)
In this instructable, I will be using a TI 84+ Silver Edition. There are only a few differences between the 83 and 84, so my instructable should still work with a TI 83.
Answers for the Make to Learn contest:
What did I make?
I wrote a program for Texas Instruments graphing calculators that will use the quadratic formula to solve quadratic equations.
How did I make it?
My math teacher gave every student some calculator programs a while ago. I was intrigued that you could program a calculator, and decided to look at how they were written. Using them to learn from, I began to write programs of my own. When I didn't know how to do something, I would sometimes look it up on the Internet, but mostly I used trial and error, and solved problems during spare class time.
Where did I make it?
I usually write programs at school, when I have time after a test or finishing an assignment. Most teachers have figured out that calculators can be used to play games, so I can't program while a teacher is teaching. (I suppose that's a good thing.) When I get a good idea and am excited about it, I will work on it in my free time at home.
What did you learn?
I learned how precise a computer will carry out you actions. One missing quotation mark or parentheses, or a negative sign instead of a minus sign will cause me endless trouble... and endless error messages. It can be irritating at times, but it is also nice, because it can do methodical calculations quickly and accurately.
Step 1: Formating
A big thing you have to get right when programming is the format. If you don't get it right, the calculator will let you know with an error message. You shouldn't have any problems with this as long as you remember all the quotation marks and parentheses.
For operations that require the 2nd key, I will write 2nd followed by the name of the secondary button. For example, I will write off as 2nd [OFF] , not 2nd [ON]
Almost all the features on the calculator can be found in the catalog (2nd [CATALOG]), but there is usually an easier way involving a menu, which I will try to explain.
Step 2: Making a New Program
To make a new program, press PRGM and scroll over to NEW, the press ENTER.
Next, type in whatever you want to name the program. I chose QUADFORM.
Press enter again, and a colon will show up. This is where you will write your first line.
Whenever you need to get out of the edit window for a program, don't press CLEAR. That will clear whatever you had written on that line, and won't get you out the the edit window. To get out, press 2nd [QUIT]
Step 3: The Quadratic Formula
The quadratic formula is used to solve quadratic equations in the form Ax^2 + Bx + C = 0. The formula is hard to type and get the formatting right, so it is included as a picture. The formula isn't particularly difficult, but it is tedious, so it's nice if your calculator can do it for you
For the calculator to solve this equation, A, B, and C all need to be entered. The calculator will plug the numbers into the formula, the display the answers.
Step 4: The Input
For the program to work, the calculator needs A, B, and C. These have to be input by the user when they run the program.
For the user to know what to input, the calculator asks for each variable, one at a time.
Before asking for the variables, the home screen must be cleared. To do this, the ClrHome command is used. It is found by pressing PRGM, then scrolling right to I/O and pressing 8.
Press enter for a new line.
Next, we will ask for the variable A. This is done by pressing PRGM, then scrolling right to I/O and pressing 2. This brings up the Prompt command. Next, type an A by pressing Alpha and then MATH, using Alpha like the 2nd key.
Press enter again and do the same thing, only asking for the variables B and C
Step 5: The Discriminant
The discriminant is the part of the formula under the radical: B^2 - 4AC. The discriminant has a plus or minus before it, so if it is anything other than zero, there will be two answers. If the discriminant is less than zero, there will be complex numbers because it is under a radical.
Since the discriminant has such an impact on what kind of answers we get, we want to solve in by itself first.
Get a new line (press enter) and type in the discriminant: B^2-4*A*C
This number can be stored by pressing STO>and then the variable we want to store it as, D.
Step 6: How Many Answers?
Now that we have solved for the discriminant, we need to figure out how many answers we have, and what to do with it.
This can be done with a few If-Then commands.
Type If by pressing PRGM and then Enter. Then enter D, because D is the value in question. Type = by pressing 2nd [TEST]. Then type 0. If the discriminant equals 0, we need to tell the calculator what to do next. Do this by pressing PRGM 2. If the discriminant is 0, the the formula becomes -B/2A, and we only have one answer. We want the calculator to go to a part of the program that does this. I'll call that label 1, which will be created later. To send the calculator there, use the Goto command. On a new line, type Goto by pressing PRGM 0. Then press 1 for label 1.
If the discriminant isn't 0, the calculator needs to know where to go. Do this by typing Else (PRGM 3), then on a new line type Goto (PRGM 0) 2 for label 2.
Now type End (PRGM 7) so the calculator knows the If-Then statement is done.
Step 7: Label One
Now it's time to create label one, which is what happens where the calculator goes when the discriminant is 0. Do this by pressing PRGM, then 1 for label 1.
When the discriminant is 0, the formula simplifies to -B/(2*A), so type this in. Use the STO> key to save this as E.
E is the solution to the quadratic. Before displaying the answer, the home screen needs to be cleared again. This is done by pressing PRGM, the right arrow, then 8. To show E to the user, we will use the Disp (display) command. Disp si found by pressing PRGM, scrolling over to I/O, and pressing 3. Using the alpha key, type a quotation mark. Then type whatever you want to tell the user, for example: ONE SOLUTION. Then type a closing quotation mark. Next, we want to display the actual answer, so put in a comma, then E. This is all the program needs to do, so end it by pressing PRGM and scrolling down to Stop and selecting it.
Step 8: Label 2
This is pretty much the same as label one, only there will be two equations and two answers. First, type lbl 2 (PRGM). Then type the two equations: -B + sqrt(D)/(2*A) and -B - sqrt(D)/(2*A). Store these as variables F and G. Then you need to display the answers. First, clear the home screen (PRGM right arrow). Next use the display command (PRGM right arrow 3) Use quotations, then type TWO ANSWERS and a close quotation. Now the answers, F and G, need to be displayed. Do this by pressing the comma, then F, and the comma, the G. Since this is the end of the program, the Stop command is unnecessary.
Step 9: Tips
Depending on what mode your calculator is in, you might get an error message if the discriminant is less that one, because you will get complex numbers.
If you are getting an error, check your program against the screenshots of my program.
Step 10: Guessing Game
A cool feature on the calculator as a random number generator. It is found by pressing MATH, scrolling over to PRB, and pressing 5. Then enter two numbers you want your random number to be between with comma separating them. Then press enter.
You can make a program that will generate a random number and store it as a variable. Then require the user to input a guess. Using the greater or less then functions (same menu as the equal sign, 2nd [TEST]) you can see if the guess is too low or too high. You can display guess higher or guess lower, along with a prompt for another guess. You can do this until the user's guess is right. It's not the best game, but if it's all you have in class...
Step 11: Date
A cool feature is the dbd( function. It will find the days between two dates. The formatting is rather specific, so be careful. Type the first day, then the first month (including leading zero for months up to September), a decimal point, then the last two digits of the first year. Type a comma, then enter the second date the same way.
Remembering the formatting is a pain, as is typing it out, so I wrote is as a program that asks for the day, week, and year as 3 variables. It gets the current date from the getDate command.
There are many things that can be done with a graphing calculator beyond what I have written or even know. If you have any questions, or have any cool ideas for a program, write a comment below.