TI-84 Programming Tutorial
Master TI-BASIC programming on your TI-84 calculator. Learn to create programs, games, and custom functions with step-by-step tutorials, practical examples, and optimization techniques.
Game Development Tips
โข Start with simple games and add features gradually
โข Use getKey for real-time input in graphics games
โข Keep game loops efficient to maintain smooth performance
โข Test boundary conditions and edge cases thoroughly
โข Add sound effects using the Tone command for better experience
๐ Getting Started with TI-BASIC
TI-BASIC is the built-in programming language of the TI-84 calculator. It allows you to create custom programs to automate calculations, create games, and build useful tools for math and science.
Creating Your First Program
Let's start by creating a simple "Hello World" program to understand the basics.
Program Creation Steps:
Disp "HELLO WORLD"
Disp "Welcome to TI-BASIC!"
Pause
Running Your Program
Once you've written your program, you need to know how to execute it.
Running Programs:
Welcome to TI-BASIC!
Press any key to continue...
Program Management
Learn essential program management tasks for efficient development.
Task | Menu Path | Steps | Notes |
---|---|---|---|
Edit Program | PRGM โ EDIT | Select program, press ENTER | Makes changes to existing code |
Delete Program | MEM โ MGMT โ 7:Prgm | Select program, press DEL | Permanently removes program |
Rename Program | Edit โ Change first line | Edit PROGRAM:NAME line | Must follow naming rules |
Copy Program | Edit โ Copy code | Create new, paste code | Useful for variations |
Archive Program | MEM โ MGMT โ 5:Archive | Select program type | Protects from RAM resets |
Program Naming Rules
โข Program names can be 1-8 characters long
โข Use only letters and numbers (A-Z, 0-9)
โข Names are case-insensitive (HELLO = hello)
โข Avoid names that conflict with built-in functions
โข Choose descriptive names for easy identification
๐ Basic Programming Concepts
Understanding fundamental programming concepts is essential for creating effective TI-BASIC programs. Let's explore variables, input/output, and basic program structure.
Variables and Data Types
TI-BASIC supports several types of variables for storing different kinds of data.
Variable Type | Examples | Range/Limits | Usage |
---|---|---|---|
Real Numbers | A, B, X, Y | ยฑ1ร10โปโนโน to ยฑ9.9999...ร10โนโน | General calculations |
Lists | L1, L2, Lโ | Up to 999 elements | Arrays of numbers |
Matrices | [A], [B], [C] | Up to 99ร99 elements | 2D data arrays |
Strings | Str1, Str2, Str0 | Up to 255 characters | Text and messages |
Graphics | Pic1, Pic2, Pic0 | 95ร63 pixels | Images and graphics |
Input and Output Commands
Interacting with users is fundamental to useful programs.
Disp "Enter a number:"
; Get user input
Input "Number: ",A
; Display variable
Disp "You entered:",A
; Prompt for multiple inputs
Prompt B,C
Mathematical Operations
TI-BASIC supports all standard mathematical operations and functions.
Operation | Symbol | Example | Result |
---|---|---|---|
Addition | + | 5 + 3 | 8 |
Subtraction | - | 10 - 4 | 6 |
Multiplication | * | 6 * 7 | 42 |
Division | / | 15 / 3 | 5 |
Exponentiation | ^ | 2^3 | 8 |
Square Root | โ( | โ(16) | 4 |
Absolute Value | abs( | abs(-5) | 5 |
Your First Useful Program
Let's create a program that calculates the area of a circle.
ClrHome
Disp "CIRCLE AREA CALCULATOR"
Disp ""
Input "Radius: ",R
ฯ*R^2โA
Disp "Area =",A
Pause
Memory Considerations
TI-BASIC programs run in RAM, which is limited. Large programs or those using many variables may cause "ERR:MEMORY" errors. Archive important programs to protect them from RAM clearing.
๐ Control Structures
Control structures allow your programs to make decisions and repeat actions. These are essential for creating intelligent, interactive programs.
Conditional Statements (If-Then-Else)
Use conditional statements to make your programs respond differently based on user input or calculations.
If A>0
Then
Disp "Positive number"
End
; If-Then-Else
If A>0
Then
Disp "Positive"
Else
Disp "Zero or Negative"
End
Comparison Operators
These operators are essential for creating conditions in your programs.
Operator | Meaning | Example | True When |
---|---|---|---|
= | Equal to | A = 5 | A equals 5 |
โ | Not equal to | A โ 0 | A is not zero |
> | Greater than | A > 10 | A is greater than 10 |
โฅ | Greater than or equal | A โฅ 0 | A is zero or positive |
< | Less than | A < 100 | A is less than 100 |
โค | Less than or equal | A โค 50 | A is 50 or less |
Loops
Loops allow your programs to repeat actions, making them more powerful and efficient.
For Loops
Use For loops when you know how many times to repeat something.
For(I,1,10)
Disp I
End
; Count by 2s from 0 to 20
For(I,0,20,2)
Disp I
End
; Calculate factorial
1โF
For(I,1,N)
F*IโF
End
While Loops
Use While loops when you need to repeat based on a condition.
randInt(1,100)โN
0โG
While Gโ N
Input "Guess: ",G
If G>N
Disp "Too high"
If G<N
Disp "Too low"
End
Disp "Correct!"
End
Practice Program: Grade Calculator
Let's combine what we've learned to create a useful grade calculator.
ClrHome
Disp "GRADE CALCULATOR"
Input "Number of grades: ",N
0โS
For(I,1,N)
Input "Grade "+toString(I)+": ",G
S+GโS
End
S/NโA
Disp "Average: ",A
If Aโฅ90
Disp "Grade: A"
If Aโฅ80 and A<90
Disp "Grade: B"
If Aโฅ70 and A<80
Disp "Grade: C"
If Aโฅ60 and A<70
Disp "Grade: D"
If A<60
Disp "Grade: F"
Pause
Control Structure Best Practices
โข Use proper indentation to make code readable
โข Always match If with End statements
โข Prefer loops over repetitive code
โข Use meaningful variable names (I for index, N for count)
โข Test edge cases (what if user enters 0 grades?)
๐ Advanced Features
Advanced TI-BASIC features allow you to create sophisticated programs with graphics, file operations, and complex data handling.
Working with Lists
Lists are powerful for handling multiple data values efficiently.
1,2,3,4,5โLโ
; Access list elements
Lโ(3)โA ; A = 3
10โLโ(2) ; Change 2nd element to 10
; List operations
dim(Lโ)โS ; Get list size
sum(Lโ)โT ; Sum all elements
max(Lโ)โM ; Find maximum
min(Lโ)โN ; Find minimum
; Sort list
SortA(Lโ) ; Sort ascending
SortD(Lโ) ; Sort descending
Graphics and Animation
Create visual programs using the calculator's graphics capabilities.
ClrDraw
AxesOff
GridOff
; Draw points and lines
Pt-On(50,30) ; Draw point at (50,30)
Line(0,0,95,63) ; Draw diagonal line
Circle(47,31,20) ; Circle at center with radius 20
; Text on graphics screen
Text(10,10,"Hello Graphics!")
; Simple animation
For(X,0,90,5)
ClrDraw
Pt-On(X,30)
DispGraph
End
Subroutines and Modularity
Break complex programs into smaller, manageable pieces.
PROGRAM:MAIN
Menu("CALCULATOR","Add",A,"Subtract",S,"Quit",Q)
Lbl A
prgmADD ; Call ADD program
Stop
Lbl S
prgmSUB ; Call SUB program
Stop
Lbl Q
Stop
Memory Management
The TI-84 has limited RAM (~24KB). Large programs or extensive use of lists/matrices can quickly fill memory. Always test programs on a calculator with typical memory usage.
๐ฎ Game Development
Creating games is one of the most exciting aspects of TI-BASIC programming. Games help you learn advanced programming concepts while creating something fun.
Game Design Principles
Before coding, consider these fundamental game design elements.
Element | Description | Implementation | Example |
---|---|---|---|
Player Input | How players control the game | getKey, Input, Menu | Arrow keys for movement |
Game State | Current condition of game | Variables, lists | Player position, score, lives |
Graphics | Visual representation | Pt-On, Text, Pixel test | Player sprite, obstacles |
Game Loop | Main program cycle | While loop | Update, draw, check conditions |
Win/Lose Conditions | How game ends | If statements | Reach goal, lose all lives |
Simple Game: Number Guessing
Let's start with a text-based guessing game to learn game programming basics.
ClrHome
Disp "NUMBER GUESSING GAME"
Disp "I'm thinking of a number"
Disp "between 1 and 100"
randInt(1,100)โN
0โT ; Tries counter
0โG ; User's guess
While 1 ; Game loop
; Increment tries
T+1โT
Input "Guess #"+toString(T)+": ",G
If G>N
Disp "Too high!"
If G<N
Disp "Too low!"
End
If G=N
Disp "Correct! You got it in"
Disp T," tries"
Pause
Stop
End
Graphics-Based Game: Snake
Now let's create a simple Snake game using graphics.
ClrDraw
47โX ; Snake X position
31โY ; Snake Y position
1โD ; Direction (1=right, 2=down, 3=left, 4=up)
0โS ; Score
; Place food randomly
randInt(5,90)โFX
randInt(5,58)โFY
Pt-On(FX,FY)
While 1 ; Game loop
; Check for key press
getKeyโK
If K=26 ; Up arrow
4โD
If K=25 ; Down arrow
2โD
If K=24 ; Left arrow
3โD
If K=27 ; Right arrow
1โD
; Move snake
If D=1
X+2โX
If D=2
Y+2โY
If D=3
X-2โX
If D=4
Y-2โY
; Check boundaries
If X<0 or X>94 or Y<0 or Y>62
Then
Disp "GAME OVER!"
Disp "Score: ",S
Stop
End
; Check if food eaten
If abs(X-FX)โค2 and abs(Y-FY)โค2
Then
S+10โS
randInt(5,90)โFX
randInt(5,58)โFY
End
; Draw everything
ClrDraw
Pt-On(X,Y) ; Snake head
Pt-On(FX,FY) ; Food
Text(1,1,"Score:"+toString(S))
DispGraph
End
โก Optimization Techniques
Writing efficient TI-BASIC code is crucial for creating responsive programs. Learn techniques to make your programs run faster and use memory more effectively.
Speed Optimization
Several techniques can significantly improve your program's execution speed.
Technique | Slow Method | Fast Method | Speed Gain |
---|---|---|---|
Variable Storage | A+1โA | IS>(A,MAX) | ~2x faster |
List Operations | For loop with Lโ(I) | Built-in list functions | ~5x faster |
String Building | Str1+Str2โStr1 | Pre-allocate string size | ~3x faster |
Graphics | Multiple Pt-On calls | StorePic/RecallPic | ~4x faster |
Calculations | Repeated complex math | Store intermediate results | Variable |
Memory Optimization
Efficient memory usage prevents crashes and allows for larger programs.
DelVar A
DelVar B
; Use lists efficiently
โLโ ; Clear list
ClrList Lโ,Lโ ; Clear multiple lists
; Reuse variables
Input "Value: ",A
A*2โA ; Reuse A instead of new variable
; Archive large programs
; Use 2ND+MEMโ5:Archiveโ7:Prgm
Code Size Optimization
Smaller code means faster loading and more available memory.
A ; Instead of COUNTER
; Combine operations
A+1โA:B-1โB ; Two operations on one line
; Use implied multiplication
2A ; Instead of 2*A
ฯRยฒ ; Instead of ฯ*R^2
; Eliminate unnecessary commands
A ; Displays A (instead of Disp A)
; Use built-in functions
rand ; Random number 0-1
int(rand*6)+1 ; Dice roll 1-6
Algorithm Optimization
Choose efficient algorithms for better performance.
PROGRAM:FACTFAST
Input "N: ",N
seq(X,X,1,N)โLโ
prod(Lโ)โF
Disp F
; Fast prime checking
PROGRAM:ISPRIME
Input "Number: ",N
If Nโค1 or (N>2 and fPart(N/2)=0)
Then
Disp "Not prime"
Stop
End
For(I,3,โ(N),2)
If fPart(N/I)=0
Then
Disp "Not prime"
Stop
End
End
Disp "Prime"
Optimization Trade-offs
Remember that optimization often involves trade-offs between speed, memory usage, and code readability. Optimize only when necessary, and always test thoroughly after making changes.
๐ง Practical Applications
TI-BASIC programming shines when solving real-world problems. Here are practical programs that demonstrate useful applications for academics and daily life.
Scientific Calculator Programs
Extend your calculator's capabilities with custom scientific functions.
ClrHome
Disp "QUADRATIC FORMULA"
Disp "axยฒ + bx + c = 0"
Input "a: ",A
Input "b: ",B
Input "c: ",C
Bยฒ-4ACโD ; Discriminant
If D<0
Then
Disp "No real solutions"
Disp "Complex solutions:"
(-B)/(2A)โR
โ(-D)/(2A)โI
Disp R," + ",I,"i"
Disp R," - ",I,"i"
Else
(-B+โ(D))/(2A)โX
(-B-โ(D))/(2A)โY
Disp "xโ = ",X
Disp "xโ = ",Y
End
Pause
Physics and Engineering Programs
Solve common physics problems with automated calculations.
Menu("KINEMATICS","Find Velocity",V,"Find Distance",D,"Find Time",T,"Quit",Q)
Lbl V
Disp "v = vโ + at"
Input "Initial velocity: ",V0
Input "Acceleration: ",A
Input "Time: ",T
V0+ATโV
Disp "Final velocity: ",V
Pause
Stop
Lbl D
Disp "d = vโt + ยฝatยฒ"
Input "Initial velocity: ",V0
Input "Acceleration: ",A
Input "Time: ",T
V0T+0.5ATยฒโD
Disp "Distance: ",D
Pause
Stop
Lbl Q
Stop
Financial Calculator Programs
Create programs for financial calculations and planning.
ClrHome
Disp "COMPOUND INTEREST"
Disp "A = P(1 + r/n)^(nt)"
Input "Principal ($): ",P
Input "Annual rate (%): ",R
R/100โR ; Convert to decimal
Input "Times compounded/year: ",N
Input "Years: ",T
P(1+R/N)^(NT)โA
A-PโI ; Interest earned
Disp "Final Amount: $",round(A,2)
Disp "Interest Earned: $",round(I,2)
Pause
Statistics and Data Analysis
Process and analyze data sets with custom statistical programs.
ClrHome
Disp "DESCRIPTIVE STATISTICS"
Input "How many values? ",N
; Input data
For(I,1,N)
Input "Value "+toString(I)+": ",X
XโLโ(I)
End
; Calculate statistics
mean(Lโ)โM
median(Lโ)โMED
stdDev(Lโ)โSD
min(Lโ)โMIN
max(Lโ)โMAX
sum(Lโ)โSUM
; Display results
ClrHome
Disp "RESULTS:"
Disp "Mean: ",round(M,3)
Disp "Median: ",MED
Disp "Std Dev: ",round(SD,3)
Disp "Min: ",MIN
Disp "Max: ",MAX
Disp "Sum: ",SUM
Pause
Utility Programs
Create helpful utility programs for everyday calculator use.
Menu("UNIT CONVERTER","Temperature",T,"Length",L,"Weight",W,"Quit",Q)
Lbl T
Menu("TEMPERATURE","F to C",FC,"C to F",CF,"Back",B)
Lbl FC
Input "Fahrenheit: ",F
(F-32)*5/9โC
Disp "Celsius: ",round(C,2)
Pause
Goto T
Lbl CF
Input "Celsius: ",C
C*9/5+32โF
Disp "Fahrenheit: ",round(F,2)
Pause
Goto T
Lbl Q
Stop
๐ Debugging & Testing
Every programmer encounters bugs. Learning to effectively debug and test your TI-BASIC programs is essential for creating reliable, professional-quality code.
Common Error Types
Understanding common TI-BASIC errors helps you identify and fix problems quickly.
Error Message | Cause | Solution | Prevention |
---|---|---|---|
ERR:SYNTAX | Invalid command syntax | Check command spelling and syntax | Use program editor carefully |
ERR:MEMORY | Insufficient RAM | Archive programs, clear variables | Optimize memory usage |
ERR:DIVIDE BY 0 | Division by zero | Add input validation | Check denominators before division |
ERR:INVALID DIM | List/matrix size error | Check list dimensions | Validate list operations |
ERR:ARGUMENT | Invalid function argument | Check function parameter ranges | Validate inputs before calculations |
Debugging Techniques
Use these systematic approaches to find and fix bugs in your programs.
PROGRAM:DEBUG
Input "Enter N: ",N
Disp "DEBUG: N = ",N ; Debug output
If Nโค0
Then
Disp "DEBUG: Invalid input"
Stop
End
1โF
For(I,1,N)
Disp "DEBUG: I=",I," F=",F
F*IโF
End
Disp "Result: ",F
Input Validation
Proper input validation prevents many runtime errors.
ClrHome
Disp "SAFE DIVISION"
; Get and validate first number
Lbl A
Input "Numerator: ",A
If Aโ int(A) and abs(A)>1E10
Then
Disp "Number too large!"
Pause
Goto A
End
; Get and validate denominator
Lbl B
Input "Denominator: ",B
If B=0
Then
Disp "Cannot divide by zero!"
Pause
Goto B
End
; Perform calculation
A/BโR
Disp "Result: ",R
Pause
Testing Strategies
Systematic testing ensures your programs work correctly in all situations.
Program Testing Checklist:
Error Handling Patterns
Implement robust error handling to create professional programs.
ClrHome
; Main program loop with error handling
Lbl MAIN
Menu("PROGRAM","Calculate",C,"Help",H,"Quit",Q)
Lbl C
; Try calculation
Input "Value: ",X
; Validate input
If X<0
Then
Disp "Error: Negative input"
Disp "Please use positive numbers"
Pause
Goto MAIN
End
; Perform calculation
โ(X)โR
Disp "Square root: ",R
Pause
Goto MAIN
Lbl H
ClrHome
Disp "HELP:"
Disp "This program calculates"
Disp "square roots of positive"
Disp "numbers only."
Pause
Goto MAIN
Lbl Q
ClrHome
Disp "Thanks for using this program!"
Stop
Professional Programming Habits
โข Always validate user input before processing
โข Provide clear, helpful error messages
โข Include help or instruction screens
โข Test with a variety of input scenarios
โข Comment your code for future maintenance
โข Use consistent naming conventions
Start Programming Today!
Put your new TI-BASIC skills to work! Use our free online TI-84 calculator to practice programming, test your code, and build amazing programs and games.
๐ป Start Programming Now