10 Minutes of Code:
TI-84 Plus CE &
Short, easy-to-teach activities designed to be completed in order, using TI-84 Plus CE and TI-Innovator™ technology.
Unit 1: Getting Started with the TI-Innovator™ Hub
Skill Builder 1 Your First ProgramDownload Teacher/Student Docs
In this first lesson for Unit 1, you will learn about working in the Program Editor to write a program that controls a light on the TI-Innovator™ Hub.
- Use the TI-84 Plus CE Program Editor
- Use the Send( command to control a light on the TI-Innovator™ Hub
- Introduction to the Wait statement
- Timing on the TI-Innovator™ Hub and the calculator
Connect the TI-Innovator™ Hub to the TI-84 Plus CE. The calculator will turn on. On the TI-Innovator™ Hub, a green light illuminates, indicating that the TI-Innovator™ Hub has power and is ready.
When learning to program a calculator with the TI-Innovator™ Hub, you will be learning to program in two separate but connected worlds: the calculator and the TI-Innovator™ Hub.
When writing a program on the calculator, use the [prgm] key to paste commands into the program
- The Send( command is used to send commands the TI-Innovator™ Hub that produce a physical reaction (lighting up a light, making a sound, turning on a motor, etc.).
- The TI-Innovator™ Hub commands are also found on the [prgm] key under the HUB menu.
Setting up the LIGHT Program:
Your first program will tell the TI-Innovator™ Hub to turn on the red LIGHT (LED) for 5 seconds.
- To begin writing a new program, press [prgm] > New.
- Type a name for the program (we use the name LIGHT1 here), and press enter.
Your program consists of only one line of code:
Send("SET LIGHT ON TIME 5")
LIGHT is the name of the red LED.
To create this statement:
- Press the [prgm] key, and select the HUB menu.
- Select the Send("SET... menu item.
- Then, select the LIGHT from the Send("SET... submenu.
- Finish the statement by completing the rest of the command.
- To access ON and TIME, press the [prgm] key, select the HUB menu, and then select the Settings submenu.
- Enter the number 5 for 5 seconds.
Send(“SET LIGHT ON TIME 5”)
Don't forget to close the quotation marks ([alpha] [+]) and parentheses at end of the statement. If needed, the space character is on the 0 (zero) key.
The complete program is shown to the right.
The Send( ) command will send the string (the text in quotes) to the TI-Innovator™ Hub.
Running the Program:
- Make sure your TI-Innovator™ Hub is connected to the calculator.
- Press [ALPHA] [GRAPH] (F5*), and then [ENTER] to select ‘Execute Program’. This quits the Program Editor and runs the program on the home screen.
* The F5 MENU key, first included in OS v5.3, is only available from within the Program Editor. It contains some additional useful editing tools like Undo Clear, Cut, Copy, and Paste, and more. These are very handy new features that you will appreciate as you write more complex programs.
If the command is written correctly, the LIGHT (the red LED) will light up for 5 seconds. If there’s an error in the TI-Innovator Hub instruction, the red light flashes once and a beep will sound.
The calculator displays ‘Done’ when the program ends. Notice that the program actually ends before the light goes off. To make the program end when the light goes off, we have to tell the calculator to Wait as long as the light is on.
To add a statement to the program, we need to edit it.
- Press [prgm] and arrow over to EDIT.
- Select your program name from the list.
- Arrow down to the end of the program code.
- Press [enter] to add a new line.
- Add the statement Wait 5 by pressing [prgm], arrowing down to Wait in the CTL menu, and pressing enter. Then, enter the number 5.
Run the program again. If the program was the last item on the home screen, simply press [enter] to rerun it. The program will end at roughly the same time the red light goes off.
We can remove the TIME element of the Send instruction and control the timing using the Wait command in the calculator. Since the LED will stay on once it is turned on, you will also have to turn the light OFF in your program.
- To turn the light off, use the statement:
Send(“SET LIGHT OFF”)
- Add statements to the program to make the light blink many times.
Skill Builder 2 Input and ColorDownload Teacher/Student Docs
In this second lesson for Unit 1, you will learn about input to a program and controlling the COLOR LED on the
- Use the Prompt statement and the Input statement
- Control the COLOR LED
- Use the new Program Editor F5 menu ([ALPHA] [GRAPH]) for enhanced editing features
The COLOR LED (light emitting diode) has three color ‘channels’: red, green, and blue. This is often referred to as an “RGB LED”. Computer screens, phone screens and TV screens all use a large number of these LEDs to create images.
To get a particular color, you have to mix the right amounts of these three colors red, green and blue. Many other colors are possible with the right mix of these three primary colors.
In this program, you will experiment with the COLOR LED. You will enter numeric red, green, and blue values into the program to direct the LED to light up in the color that you chose.
In addition to studying the COLOR LED, we are introducing the first program command to accept input from the user while the program is running: Prompt.
The Prompt statement allows the user to enter a value for a variable while the program is running. It’s called Prompt because it provides a visual message (the name of the variable and a question mark) when it is being processed. In response, the user enters a value for the variable.
Possible syntax of the statement:
- Prompt <variable>
- Prompt <variable1>, <variable2>, <variable3>,…
The numeric variables in the TI-84 Plus CE are the letters A..Z and Ɵ (theta). Real or complex numbers can be stored.
In this program, we will use Prompt to ask for red, green, and blue numeric values (0 – 255, inclusive) and then send them to the COLOR LED. In the interest of efficiency, we’ll prompt for all three variables in the one statement.
Setting up the Color Program:
- Press [prgm] > New, type a name for the program (we use the name COLOR1 here), and press enter.
- Add a ClrHome statement by pressing [prgm] arrowing to I/O, and selecting ClrHome.
- Add a Prompt statement by pressing [prgm], arrowing over to I/O, and selecting Prompt.
- Add the variable R by selecting [ALPHA] [X].
- Add the variables G and B for the Green and Blue values, respectively. Be sure to add a comma between variables. Press enter.
Now we’ll use the Send( command to send an instruction to the
- Press [prgm] and arrow over to the HUB menu.
- Select Send(“SET… and then select COLOR.
You cannot send the variables R, G, and B as the color values in the Send( statement because the letters R, G and B would be sent to the TI-Innovator Hub rather than the values of the variables.
We need to use a special function, eval( ), from the HUB menu which is designed to convert the value of an expression in the calculator into a string representation that the
Complete the Send Statement:
- Add the eval( function by pressing [prgm], arrowing over to the HUB menu, and selecting eval(.
- Type the letter R and the right parenthesis.
- Add a space ([ALPHA]).
- Repeat the eval() function two more times for G and B. Don’t forget to add a space in between.
- Finally, after the third eval() function, add the closing double quotation mark for the string and the right parenthesis for the Send( command.
The completed statement will be:
Send(“SET COLOR eval(R) eval(G) eval(B)”)
Running the Program:
Make sure the TI-Innovator™ Hub is connected to the calculator.
To run a program from the Program Editor:
- Press [ALPHA] [GRAPH], which is the F5* key.
- Select Execute Program
This sequence of steps quits the Program Editor and runs the program on the home screen.
- You will get three prompts on a cleared home screen, one for R, one for G, and one for B.
- Enter numbers between 0 and 255, inclusive, for each variable, pressing enter each time.
- After entering the third value, notice the color of the COLOR LED on the TI-Innovator™ Hub.
To try a different set of values, press [enter] to rerun the program, and enter three new values.
Skill Builder 3 Input and SoundDownload Teacher/Student Docs
In this third lesson for Unit 1, you will learn another method to get user input into a program and how to control the SOUND on the
- Use the Input statement
- Control the frequency and timing of the speaker (SOUND)
You control the sound coming out of Sound by sending a frequency value. Sound frequencies are measured in Hertz (Hz), or ‘cycles per second’.
The Input statement, like Prompt, is found in the [PRGM] I/O menu. It is also used to get input from the user, but it contains a feature that lets the programmer create a more meaningful message rather than the simple Prompt studied earlier.
Statement Syntax: Input <String> , <Variable>
In this sound program, we’ll use the Input statement.
Setting up the SOUND program:
- Start a new program, and name it SOUND1.
- Add the ClrHome and Input statements from the [PRGM] I/O menu.
- After the Input command, use [A-LOCK] ([2nd][ALPHA]) to type the string of characters “FREQUENCY?”.
- Turn off the alpha lock to type the comma.
- Then add the variable that will represent the frequency, F ([ALPHA] [COS]).
- Press [ENTER].
- Add another Input statement to let the user enter the time for which the sound should play.
As with the COLOR program in the previous skill builder, you need to use the eval( ) function to evaluate the variables F and T.
Finishing up the SOUND program:
- Press [PRGM], arrow over to the HUB menu, and select Send(“SET….
- Select SOUND
- Press [PRGM], arrow over to the HUB menu, and select eval(.
- Add the variable F, and close the parentheses.
- Type a space ([ALPHA]) and then add another eval( function for the variable T.
- Add the variable T, and close the parentheses.
- Add the closing quotation mark and the parentheses for the Send( command.
Running the program:
- Press [ALPHA] [GRAPH]  (Execute Program).
- Enter the frequency 440 and the time 5.
- This will play the tone 440Hz for 5 seconds. This means that the speaker vibrates 440 times a second for 5 seconds.
- In a noisy environment, you might have to hold the
TI-Innovator™ Hubclose to your ear to hear the tone.
- Press [ENTER] to rerun the program with another frequency and time.
- Experiment with other frequencies.
Application Traffic LightDownload Teacher/Student Docs
Write a program that controls a traffic light.
- Control the COLOR LED to simulate a traffic light using a single bulb
- Create a sequence of statements with proper timing controls
Your task is to write a program that controls a traffic light. The light will be simulated using the COLOR LED on the
The COLOR LED should switch from green to yellow to red AND from red to green. Timing is up to you.
Your program will have a sequence of statements that simulate the change from RED to GREEN to YELLOW to RED. A sequence control structure in programming is a set of statements that are processed one after another, from top to bottom, without interruption.
Using Disp and Pause:
The Disp command displays a message on the HOME screen of the calculator. It can be used to display the value of a variable as in Disp X, or it can display a string like in the example on the right. You can find Disp by pressing [PRGM] and arrowing over to I/O and selecting Disp.
The Pause command displays a message as well but stops the calculator from processing any more statements until the user presses [ENTER]. You can find Pause by pressing [PRGM] and selecting Pause.
Setting up the Title Screen:
- Begin a new program, and call it APPLIC1.
- Add a ClrHome statement from [PRGM] I/O menu.
- Add Disp by pressing [PRGM], arrowing over to I/O, and selecting Disp.
- In quotation marks ([ALPHA] [+]), add the message "TRAFFIC LIGHT".
- Add Pause by pressing [PRGM] and selecting Pause
- In quotation marks, add the text "PRESS ENTER..." as shown.
Set the Colors:
First we set the color to red by setting the RGB values of 255, 0, 0.
In the example on the right, we use a Wait statement to tell the calculator to wait 5 seconds before sending the next command to the
Your task is to add the statements to make the light green, then yellow, then red again.
Challenge: Add SOUNDs to indicate the color of the light.
- Skill Builder 1
- Skill Builder 2
- Skill Builder 3
Unit 2: For Loops with TI-Innovator™ Hub
Skill Builder 1 Blink the LIGHTDownload Teacher/Student Docs
In this first lesson for Unit 2, you will learn about the For loop in the calculator through a program that makes the LED LIGHT blink while displaying information on the calculator screen.
- Learn about the For loop
- Make the light blink
- Use the Disp statement for text and variables
Let’s write a program to make the LED LIGHT blink a certain number of times. With other input statements, you can also control the amount of time that the light is on and off.
This program introduces you to the For…End loop.
Setting up the program:
- Start a new program, and name it LIGHT2.
- Add ClrHome by pressing [PRGM], arrowing over to I/O, and selecting ClrHome.
- Add Disp by pressing [PRGM], arrowing over to I/O, and selecting Disp.
- Within quotation marks, add BLINK as shown.
- Add Input by pressing [PRGM], arrowing over to I/O, and selecting Input.
- Within quotation marks, add NUMBER OF TIMES? as shown.
- Next add a comma and the variable N.
Adding the For Loop:
- Add the For( statement by pressing [PRGM] and selecting For(.
- Add the rest of the statement’s arguments, I,1,N).
- This statement means “For I going from 1 to N by ones”.
- Press [ENTER] a few times to create blank lines that we’ll fill in later, and then add the End statement to the program by pressing [PRGM] End.
- Don’t worry about how many blank lines to enter. You can always add more lines if you need them, and blank lines have no effect when you run the program.
- The block of statements between For and End is called the ‘loop body’. It is this section of code that will be processed N times thanks to the work done by the For loop.
Note: To insert a blank line into a program, open the F5 menu ([ALPHA] [GRAPH]), and use Insert Line Above.
We want the light to blink ON and OFF N times. We also want the calculator to display the number of the blink.
Start the loop body with Disp I which will display the loop control variable.
Now add statements to turn the light ON and OFF as shown.
- Add Send("SET LIGHT from the [prgm] HUB menu.
- Add the word ON from the [prgm] HUB > SETTINGS submenu.
- Remember to add the closing quotation mark and right parenthesis, and press [ENTER].
- Add Wait (in seconds) from the [prgm] HUB menu so that the calculator waits before sending the next command.
- In our program, we use 1 second but you can use any values you like, including decimals.
- Copy the Send( command using [ALPHA] [GRAPH]  and [ALPHA] [GRAPH]  (Copy Line and Paste Line). Edit the statement to change ON to OFF.
- Copy the Wait statement using the same method.
- Run the program by pressing F5 ([ALPHA] [GRAPH]) and then [ENTER]. You should see the light blink and the counter increase on the home screen.
Here’s a challenge: Add Input statements at the top of the program (before the For( statement) to set the timing for each of the two Wait values (the ON time and the OFF time). Use those variables instead of numbers in the Wait statements.
Run the program again. Observe the blinking and the values displayed on the calculator screen.
Skill Builder 2 Loop through COLORsDownload Teacher/Student Docs
In this second lesson for Unit 2, you will learn about controlling the intensity of the three colors of the COLOR LED on the
- Use For loops to control each of the three color channels on the COLOR LED
The red, green, and blue values (from 0 to 255) sent to the COLOR LED determine the brightness of each color channel. This program demonstrates varying the amount of each color gradually to transition through some of the over 16 million (256³) colors possible. You will again use some For loops in your program.
Creating a Color Changer Program:
- Start a new program and call it COLOR2.
- Add ClrHome and add Disp with the title the program as shown.
- Add Input and in quotations marks add WAIT?.
- Then add a comma and the variable W.
- This variable will be used in a Wait statement. The lower the number, the lower the wait time, and the faster the program executes the next command.
- As shown on the right, also input a STEP value to be used in the For loop to control the speed of the color change.
Our program will gradually (depending on the wait and step values) increase the RED intensity, then add GREEN, then gradually take away the RED, then add BLUE, take away GREEN, then add RED to the BLUE, then take away the BLUE, then finally take away the RED. This is a rather long program, and you can run it after you complete each of the For loops to test the code.
- It’s a good practice when working on more complicated programs to insert both the For( statement and its corresponding End statement at the same time so that you don’t forget it later on. Just leave some blank lines in the loop body by pressing enter a few times.
Complete the First Loop:
- Add the rest of the components of the For( statement to make the value of I go from 0 to 255. Use the loop variable I and the step variable S.
- Add the Send(“SET COLOR statement from the [prgm] HUB menu.
- Use the eval( function from the [prgm] HUB menu for the variable I to control the red channel, and set the GREEN and BLUE channels to 0.
- Remember to close the quotes and the parentheses.
- Follow the Send statement with the Wait statement using the variable W that you used in the Input statement earlier.
- After the End of this first For loop, you can use the Pause statement with a message in order to admire that bright red LED.
Add the Green Light Loop:
Now we’ll build another For loop to add GREEN to the LED. We will re-use the loop variable I and the step variable S. However, this time we want to only control the GREEN channel and not touch the RED channel. We can do this in two ways:
Send(SET COLOR 255 eval(I) 0”)
(since we know that the RED is all the way on and the BLUE is off)
Send(“SET COLOR.GREEN eval(I)”)
This second statement controls only the GREEN channel and does not affect the RED and BLUE channels. In both cases, notice that we can reuse the variable I from the first For loop.
In the image to the right, note that we chose to use Send(“SET COLOR.GREEN eval(I)”).
- Add the Wait statement inside the loop body using the variable W.
- Add the Pause statement after the End of the loop again to admire the new color. What color is that?
Now we want to gradually decrease the amount of RED so that we are left with only GREEN.
To decrease in a For loop, we start with the highest number, go to the lowest number, and use a negative step value:
For(I, 255, 0, -S)
starts at 255 and subtracts S in each step of the loop until the variable I is less than 0 when the loop ends. Be sure to use the [(-)] ‘negative’ key and not the subtraction key. That would cause an error.
We only want to change the RED channel, so we’ll use COLOR.RED in the Send statement.
The rest of this loop is similar to the first two loops we constructed. The image to the right shows only the keywords entered.
Can you complete each of these statements? If not, refer to the next step.
The image to the right shows the completed section that removes the RED gradually. At the end of this loop, you should see a bright GREEN color.
- Now add a loop to add BLUE.
- Next add a loop to remove GREEN.
- Then add a loop to add RED again.
- What color do you see at the end of these loops?
- Then add a loop to remove BLUE.
- Finally, add a loop to remove RED.
- What color is the LED at the end of the program?
- What happens when all three color channels are 0?
Skill Builder 3 Loop through the musical notesDownload Teacher/Student Docs
In this third lesson for Unit 2, you will learn about the relationship between the frequencies of the musical scale and write a program to play notes that musicians have used for many centuries.
- Explain the ‘twelfth root of two’ relationship of the musical scale
- Write a program that plays successive notes in a scale
A Little Music Theory
Musical notes are determined by the frequency of a vibrating object such as a speaker, drum head, or string as in a guitar or piano. The notes of the musical scale have a special mathematical relationship. There are 12 steps in an octave. If a note has frequency F, then the very next note has frequency F × 12√2.
Multiplying a note’s frequency by 12√2 or 21/12 (the twelfth root of 2) twelve times results in a doubling of the original frequency, so the last note in the octave (or the first note in the next octave) has frequency of
The human ear tends to hear both notes an octave apart as being essentially "the same", due to closely related harmonics. For this reason, notes an octave apart are given the same name in the Western system of music notation—the name of a note an octave above C is also C. The intervals between these notes are called ‘semitones’.
In this project, we’ll take advantage of the 21/12 principle to generate the 12 notes in an octave.
Middle C has a frequency of 261.64Hz. An octave above Middle C, also known as Treble C, has a frequency 2 × 261.64Hz or 523.28Hz. There are 12 steps (semitones) between these two notes, and each step is 21/12 times the note before it.
In the image to the right, we entered 261.64 on the HOME screen. Then, in the next statement, the value is just multiplied by 21/12.
The calculator supplied Ans at the beginning because the multiplication symbol requires something in front of it. Just pressing [ENTER] repeatedly creates the sequence of answers shown.
We will incorporate this repetitive principle into our program. If you continue the progression, the twelfth answer will be 523.28, two times the starting value, because
Setting up the Program:
- Start a new program and name it SOUND2.
- Add the commands ClrHome and Disp , and type the message within quotation marks as shown.
- Assign the starting frequency, 261.64 to the variable F using the [STO →] key.
- This variable will represent each of the 12 notes in the scale.
Setting up the For Loop:
- Add a For( loop that goes from 1 to 12 (for the twelve notes).
- Add Send( “SET SOUND statement from the HUB menu.
- Add eval( for the variable F as shown. Be careful with the quotation symbols and parentheses!
Evaluating the frequency:
- Multiply F by 21/12, and store the result back into F:
- This statement takes the current value of F and changes it to the next higher note’s frequency on the scale.
- Run the program. Did you hear anything? Is it what you expected?
Modifying the Program:
Try adding the TIME parameter to the SEND( “ SET SOUND command, and be sure to add an equivalent Wait statement to the program to let each note finish playing.
If a new command is received by the
When you run this program you will not hear the usual 'do-re-mi-fa-sol-la-ti-do' sequence. That's only eight notes. The others correspond to the black keys on a piano. How can you get the program to only play the correct eight notes?
Application Computer MusicDownload Teacher/Student Docs
You will use the random number generator on the
- Use the For loop to control the number of notes
- Use the random number generator to create random musical notes
Your task is to complete a program that asks for the number of notes to play, and then uses a For loop to play the given number of random notes. As the note is being played, the frequency should be displayed on the calculator screen using Disp.
In this application, we will use the randInt( ) function of the
- From the HOME screen, locate randInt( on the math > PROB menu.
- This command takes two (or three) arguments. Initially, you will get a ‘Wizard’.
- Enter a lower and upper value and leave n: empty.
- n is used to create a list of n numbers.
- Select Paste to put the command on the HOME screen and press enter.
- From then on, just up-arrow to the previous command, press enter to reuse it, and edit the two arguments to see the output of the function.
Combine this randInt( ) function with our musical notes formula to get the program to generate random notes based on the 21/12 relationship between the notes. The important part of the code is:
As you can see on the chart, the frequency of the note A in the first octave is 55Hz. The range 0 to 59 in the randInt function represents the 60 notes in the chart. Notice the use of N in 2^(N/12) to generate the Nth note from A in the first octave. When N is zero, then the frequency is 55Hz, since 2^0 is 1.
Use a Wait command to keep the calculator in sync with the music.
- Skill Builder 1
- Skill Builder 2
- Skill Builder 3
Unit 3: BRIGHTNESS, IF, and WHILE with TI-Innovator™ Hub
Skill Builder 1 BRIGHTNESS measurementsDownload Teacher/Student Docs
In this first lesson of Unit 3, we investigate the onboard light sensor, BRIGHTNESS, and introduce the Output( statement in TI-Basic to illustrate a technique for efficiently displaying a number of different lengths using Output(.
- Read the BRIGHTNESS sensor
- Introduce the While loop
- Use the Output( statement
- Introduce toString( and concatenation
In the previous lessons, we have only been sending instructions to the
In this unit, we will work with the onboard light sensor and use the value in our program to create a ‘light meter’. The light sensor produces values in the range (0 to 100) in decimal form.
Obtaining the light level value from the
- Send(“READ BRIGHTNESS”)
Setting up the Program:
- Start a new program, and name it BRIGHT1.
- Add the commands ClrHome and Disp to display the title as shown to the right.
- Press [prgm] and arrow over to the HUB menu.
- Select Send(“READ… and then select BRIGHTNESS.
- Press [prgm], and arrow over to the HUB menu.
- Select Get(. Enter the variable B, and the right parenthesis.
How it works:
- READ BRIGHTNESS tells the
TI-Innovator™ Hubto read the brightness level and store that value in an onboard ‘buffer’.
- Get(B) is a calculator command to get a value from
TI-Innovator™ Hub. This statement transfers the value in the buffer on the TI-Innovator™ Hubinto the variable B in the TI-84 Plus CE. B can be replaced by any of the calculator’s numeric variables, A..Z and Ɵ (theta).
The While…End loop ([prgm] CTL menu) is used to process a block of code while a condition is true. A condition is a logical statement that can be evaluated as true or false. The relational operators and the logical operators are found on the test menu of the calculator ([2nd] [math]).
- The relational operators are =, ≠, <,>, ≤, and ≥.
- The logical operators are and, or, not, and xor.
- These operators can be used together to build compound conditions such as x>0 and y>0.
We are going to use a simple While loop that stops when the brightness value is less than 1. To terminate the program, simply cover the light sensor on the end of the
Another way of ‘breaking’ or terminating a running program is to press the ON key. You will see the error message: ERROR: BREAK at the top of the screen and have the option of 1:Quitting to the HOME screen or 2:Goto the program editor at the point where the action of pressing ON stopped the program. This is also a convenient way to continue editing the program.
Adding a While Loop:
- Before the Send( statement in your program, add the statements:
While B>1 (use the [test] menu for >)
- The statement 2→B initializes the loop. As long as the condition B>1 is true, the loop continues reading the light sensor. Once it becomes false, such as when there is no more light coming into the sensor, the loop and the program terminate.
- The End of the While loop must also be entered. Below the Get( statement, add an End statement for the end of the While loop. End is located in the CTL menu. (Press [prgm] to access the CTL menu.)
- Add the Output( statement after the Get( statement and before the End of the loop, as shown, by pressing [prgm], arrowing over to I/O, and selecting Output(.
- The Output( statement gives you great control over where on the HOME screen something should be displayed. The structure of the statement is: Output(<line#>, <column#>, <string or variable>).
- Output(3,7,“HELLO”) will place the letter “H” at line 3, column 7 of the HOME screen and the rest of the word will follow the letter “H”.
- Output(5,10,B) will place the first digit of the value of the variable B starting at line 5, column 10 of the HOME screen and the rest of the digits follow.
- Run the program with the
- You should see the title message at the top of the screen and a value in the middle of the screen that changes depending on the light intensity being read by the sensor. Note that the value shown is not a standardized value.
- To end the program, cover the light sensor on the end of the TI-Innovator™ Hub so that the brightness value displayed is less than 1.
The Output( statement does not erase trailing digits when a shorter number is displayed after a longer number. For example, if one value displayed is 1.23456 and the next value displayed is 55, then you will see 5523456. Our final modification to this program is a tricky way of correcting this problem.
To correct the ‘trailing digits’ issue, we convert the variable B into a string and add some spaces to the end of it to completely erase the previous value displayed.
toString( is found on the [prgm] I/O menu.
The final correct Output statement is: Output(5,10,toString(B)+“ ”)
There are about 10 spaces between the quotes above.
Now, when you run the program, you will see that some values are shorter than others because the spaces that we added to the string representation of B erase the previous digits.
The “+” sign used in the Output( statement is not used for addition: it is used to ‘concatenate’ (combine) two strings (sets of characters). The spaces (in quotation marks) are appended to the end of the string representation of the variable B.
Skill Builder 2 BRIGHTNESS & LIGHT with IF, WHILEDownload Teacher/Student Docs
In this second lesson of Unit 3, we’ll develop an automatic light switch that responds to ambient light, turning on when darkness falls and turning off when the amount of light increases.
- READ BRIGHTNESS
- Use a While loop
- Use If…Then…Else…End to turn the LIGHT on or off depending on BRIGHTNESS
Now write a program that detects the BRIGHTNESS value and turns a light on when it gets ‘dark’. When the room lighting gets brighter, the light goes off. This is exactly how many automatic light switches and night lights work.
Our program will read the light sensor on the
Use your brightness meter from the previous lesson to determine a suitable 'middle value' between 'lightness' and 'dark'.
Setting up the Program:
- Start a new program, and name it BRIGHT2.
- Add the commands ClrHome and Disp and an informational title after Disp, as shown to the right.
- Initialize the variable B by adding the statement 2→B.
- Add a While loop with the condition B>1. (The brightness value is very low.)
- Add End to close the while loop.
To terminate the loop and the program, cover the light sensor.
- In the While loop body, add Send(“READ BRIGHTNESS”) and Get(B) from the [prgm] HUB menu as shown.
If Statements:If statement will have two ‘blocks’ of code: one for when the condition is true and another for when the condition is false.
The structure of the multi-line statement is
<do this when true>
<do this when false>
You can add more blank lines by pressing [ins] [enter] or by using F5 ([ALPHA] [GRAPH]) menu option Insert Line Above.
Writing the Condition:
The brightness value is stored in the variable B and ranges from 0 to 100.
What is a good ‘dark’ value? We chose 25, but you can change it to any value between 0 and 100. Use your brightness meter from the previous lesson to decide on a lightness-darkness boundary value.
You could improve the program by using an Input statement for the ‘trigger’ value. Just be sure to use the Input statement before the While loop starts.
Get the ‘<’ (less than) operator from the [test] menu ([2nd] [math]).
- Turn the LIGHT ON or LIGHT OFF in the Then and Else blocks as shown.
- Run the program with the TI-Innovator™ Hub attached.
- Control the light hitting the sensor, and watch the LIGHT (the red LED on the Hub) turn on or off.
It might help to add an Output( statement from the previous lesson to display the value of B on the calculator screen and add statements in the If Then Else blocks to show whether the light is “ON” or “OFF”. You can use something similiar to:
Output(9,1,“ON ”) and Output(9,1,“OFF”)
One final note: The light will be ON when the program ends. Why? Add a statement to make sure that the light is off.
Skill Builder 3 BRIGHTNESS and COLORDownload Teacher/Student Docs
In this third lesson of Unit 3, we’ll make use of the BRIGHTNESS value to control the COLOR LED.
- Read the light sensor and control either the COLOR LED brightness or the sound coming out of the speaker
- Use conversion formulas to change from BRIGHTNESS values to COLOR values
We will build a product that reacts to the brightness in the room. The brighter the room lighting, the brighter the COLOR LED. The tricky part here is converting the BRIGHTNESS value into an appropriate COLOR value. Think of this product as an auto changing (dimming or brightening) light bulb.
BRIGHTNESS B ranges from 0 to 100.
COLOR C (all three channels) can vary from 0 to 255.
How do we convert from B to C?
Setting up the Program:
- Start a new program, and name it BRIGHT3.
- Add the commands ClrHome and Disp to display the title as shown to the right.
- Set the variable B as shown.
- Add a While loop to read the brightness using Send("READ BRIGHTNESS") and get the brightness variable with Get(B).
- Use the variable C to represent the COLOR value that we’ll send to all three channels of the COLOR LED. The conversion factor is 2.55. That is, 2.55*B→C.
Check this formula with the two pairs of values given.
When B=0 then C=2.55*0 ==> 0; when B=100 then C=2.55*100 ==> 255.
- Add a Send(“SET COLOR statement before the End of the loop. This statement will control the brightness of the color LED.
- Finally, complete the SET COLOR command by using eval(C) three times (once for each of the three color channels).
- When all three channels have the same value, then the color of the LED is white and the brightness of the LED changes depending on that value.
- Connect the
TI-Innovator™ Hub, and run the program.
- Change the brightness by pointing the light sensor at different things. Watch the intensity of the COLOR LED on the TI-Innovator™ Hub.
- To end the while loop and hence the program, cover the sensor completely so that the value of B goes below 1.
You might want to add some Output( statements to your program to see the values of B and C.
But wait! The effect is wrong! The darker the room lighting, the brighter the LED should be! How can you reverse the effect?
Application Lite MusicDownload Teacher/Student Docs
In this application, you will write a program to control the sound coming from the speaker based on changing the brightness sensed by a light sensor – hence, Lite Music!
- Write a program that converts brightness into sounds
- Review musical note frequencies and the twelfth root of 2 principle
Write a program that reads the BRIGHTNESS of a light sensor and plays a different sound depending on the brightness. There are two possible options for the sound:
- Play a frequency in the audible range (perhaps 100Hz – 1000Hz)
- Play a musical note (one of the specific harmonious sounds found on a piano or other musical instrument).
The first option would just play what sounds like ‘noise’. The second option will sound more like music, but the mathematics is a bit more complex.
This program makes the
- Start a new program, and name it APPLIC3.
- Add the commands ClrHome and Disp to display the title as shown to the right.
- Initialize the variable b by adding the statement 2→B
- Add a While loop to Read the BRIGHTNESS sensor and Get its value into a variable B.
- Add the statement to play a sound.
- Notice that we’re using the variable B for reading BRIGHTNESS and the variable F for playing the SOUND.
Your task is to complete the missing code that converts the BRIGHTNESS into an audible sound or a musical note.
For sound, use a frequency between 100 and 1000 Hz (or two frequencies of your choice).
For musical notes, try a range starting with A1 (55Hz) and going up 50 notes. (Refer to the activity studied in Unit 2, Skill Builder 3 (program SOUND2) which played the 12 notes in an octave.)
For the musical notes, you will need to convert your value to a whole number so that a note ‘number’ is correctly represented. You can use either the int( ) function or the round( ,0) function.
|int(X)→X||gives the largest integer less than X.|
|round(X,0)→X||rounds X to the nearest integer.|
- Skill Builder 1
- Skill Builder 2
- Skill Builder 3
Unit 4: Make Rover Move!
Skill Builder 1 Your First Rover ProgramDownload Teacher/Student Docs
In this first lesson of Unit 4, you will learn about working in the Program Editor to write a program that makes the TI-Innovator™ Rover move.
- Use the TI-84 Plus CE Program Editor
- Use the Send( command to CONNECT the TI-Innovator™ Rover to the TI-Innovator™ Hub
- Make the TI-Innovator™ Rover move FORWARD, BACKWARD, LEFT and RIGHT
- When writing a new program or editing an existing program, TI-Innovator™ Rover commands are found when you select [prgm], then the Hub menu, and then 7:Rover (RV)….
- To quickly reach the Rover commands, select [prgm], then select the left arrow to move to the Hub menu, and then select the number 7.
- Some portions of the final instruction, such as numeric values and optional parameters, are entered as normal keypad characters or selected from another Rover menu.
- Some Rover commands include the closing quotation mark and parenthesis and others do not, indicating that there’s (possibly) more to enter within the command. In either case, all commands need to be ended with the closing quotation mark and closing parenthesis.
Your first Rover command tells the TI-Innovator™ Hub to connect to Rover:
RV is the name of the Rover device.
To create this statement:
- First, select the [prgm] key, and then select the HUB menu.
- Then, select the Rover (RV)… submenu.
- Finally, select Send(“CONNECT RV”). The command is located near the bottom of the submenu.
Next we will add a Pause statement. This command pauses the calculator program and waits for the user to press the enter key.
- Press [enter] to move to a new line in the program.
- Press the [prgm] key and, in the CTL menu, select Pause.
- Add an appropriate message after the Pause command such as “PRESS ENTER TO START” using the Alpha keys.
When running the program, if you hear a beep from the TI-Innovator™ Hub before (or while) you see “PRESS ENTER TO START” it means that the CONNECT RV command was unsuccessful. Make sure the Rover is turned on.
Driving the Rover
- Press [enter] at the end of the Pause statement in order to add the next command which will cause the Rover to move forward.
- Press prgm > Hub > Rover (RV)…, and then select the Drive RV… menu as shown to the right.
- Select FORWARD from the Drive RV… menu.
Notice that the command that is pasted into the program is missing the closing quotation mark and the closing parenthesis. We still need to add some information.
- Add the number 1, and then add the closing quotation mark and a closing parenthesis to the command. The quotation mark is [alpha] [+] and the closing parenthesis key is above the 9 key.
- Quit the editor ([2nd] [mode]), and run the program. Be sure that there is about one foot of free space in front of the Rover.
If all is well, then the Rover should move forward. But how far? Study the movement carefully and determine what FORWARD 1 means.
The calculator displays ‘Done’ when the program ends. Notice that the program actually ends before the Rover finishes moving. The calculator and the TI-Innovator™ Hub work at different rates.
- Edit the program, and add the statement Send(“RV BACKWARD 1”) by pressing prgm > Hub > Rover (RV)… > Drive RV… > BACKWARD.
- Then add the number 1 and the closing quotation mark and closing parenthesis as you did in the FORWARD statement.
Quit the editor, and run the program again. This time, the Rover should move forward a bit and then back to its original position. If it does, congratulations! You made the Rover move.
The next two commands in the Drive RV… menu are LEFT and RIGHT. Add these two commands to your program, and run the program again. What do these instructions do?
Making it Travel
Study the program to the right, and predict what the Rover will do and where it will end up when the program ends. Enter the commands into your calculator, and run the program.
Did your program do what you expected? Can you make a program with only these commands that causes the Rover to make a rectangular pattern?
Using the New Supplemental Program Editor Menu
Access the new supplemental Program Editor menu by pressing alpha-F5. Use this menu to copy a line (5: Copy Line) and paste the line (6: Paste Line Below) below the current cursor line. You can also undo and insert lines and run the program from this menu.
Skill Builder 2 Driving FeaturesDownload Teacher/Student Docs
In this lesson, you will investigate some of the optional driving features. The four driving commands in Skill Builder 1 did not include the closing quotation mark and closing parenthesis. This is because there are other options that you can supply to the commands. This lesson investigates those options.
- Extending the driving features of the Rover
- RIGHT and LEFT options
Parameters for FORWARD and BACKWARD
These driving commands have three optional parameters:
They are found in the prgm > Hub > Rover (RV)… > RV Settings… menu. Also, SPEED rates (UNITS/S and M/S) can also be accessed in this menu.
Using DISTANCE, SPEED and TIME
Some examples of different implementations of the FORWARD command:
- FORWARD DISTANCE # is the same as FORWARD #.
- FORWARD DISTANCE # M moves the Rover # Meters.
- FORWARD # SPEED # where speed is between 1.4 and 2.3.
- Values outside this range result in a TI-Innovator™ Hub error.
- FORWARD TIME #.
You can specify any two of these three options in the FORWARD and BACKWARD commands.
You can also use eval( ) if the value you want to use is stored in a calculator variable or if you want to use the result of an expression.
SPEED and TIME Program
- The program on the right has this command already added: Send(“RV FORWARD SPEED 2.3 TIME 2”)
- Complete the program by providing the correct TIME so that Rover returns to its starting position: Send(“RV BACKWARD SPEED 1.4 TIME ?”)
Hint: DISTANCE = SPEED * TIME
RIGHT and LEFT Options
These commands by default turn the Rover RIGHT or LEFT 90 degrees but you can add a degree measure to the command to turn any angle (-360…360 degrees). Negative values are also permitted, so LEFT -90 is the same as RIGHT 90.
- Add a command to make the Rover turn RIGHT 135 degrees. You have to key in the 135 plus the closing quotation mark and closing parenthesis. The word DEGREES is not needed but is available in the RV Settings… menu for clarity.
You could also specify the angle measurement in RADIANS or GRADS but these units must be stated and are also found in the RV Settings… menu.
Some examples are shown to the right. What is the final heading of the Rover after these three statements are processed?
Skill Builder 3 Options, COLOR and timingDownload Teacher/Student Docs
In this third lesson of Unit 4, you will learn about turning to a specific angle heading, timing, and working with the COLOR LED on the Rover.
- Use the TO ANGLE command
- Use the RV.COLOR LED on the Rover
- Control timing on the calculator and the Rover
This lesson addresses three more features of the Rover:
- the TO ANGLE command (which is different from LEFT and RIGHT)
- lighting up the RV.COLOR LED onboard the Rover (labeled ‘Color’ on the top-front-left corner next to the battery level indicators)
- synchronizing your program with the Rover’s movements using Wait
The command Send(“RV TO ANGLE <number>”) is used to turn the Rover to a particular ‘heading’. When you send a command to connect the Rover, its heading is set to 0 degrees, which, in the mathematical world, is ‘East’ (facing from the origin toward the positive x-axis). In this world, North is 90 degrees, West is 180 degrees, and South is 270 degrees. See the diagram to the right.
Regardless of where the Rover is currently heading, the command Send(“RV TO ANGLE 0”) causes the Rover to turn to the direction that it was heading when the “CONNECT RV” command was issued.
The default angle measure is DEGREES but you can also specify RADIANS or GRADS (selected from the RV Settings… menu).
Send(“RV TO ANGLE 90”)
Send(“RV TO ANGLE 180”)
Send(“RV TO ANGLE 270”)
Send(“RV TO ANGLE 360”)
Did the Rover do what you expected?
Syncing Your Program With the Rover
Programs on the calculator are ‘Done’ before the Rover finishes moving. This is because the driving commands are stored in the TI-Innovator™ Hub faster than the Rover can process them. Driving commands are stored in a ‘queue’ and are processed by the TI-Innovator™ Hub when the Rover is ready for them.
In this activity, we’ll write a program to move in a random pattern and light up the RV.COLOR LED on the Rover while the Rover is moving. We’ll also make use of the TO ANGLE command and incorporate eval( ) to turn to the appropriate heading.
Setting Up the Program
- Start a new program.
- Add a For loop to have the Rover move in a random pattern. Remember that it’s a good idea to put the End of the For loop in the code now so that you don’t forget it later on. You can always add lines to the loop body if you need them. Note: The For( and End commands are in the CTL menu.
- In the loop body, add the statement to move FORWARD.
- Then, have the Rover turn to a random heading by adding the command
randInt(0,360) → H.
- Add the TO ANGLE statement to turn in the direction H.
- Run the program now to see that:
- The Rover moves in a random pattern.
- The program is ‘Done’ almost immediately while the Rover still has to move.
Since the color LED on the TI-Innovator™ Hub is hidden inside the Rover, we are given another color LED on top of the Rover to control. The name of the Rover’s color LED is RV.COLOR and works using the same controls as the onboard LED. You can use any of the four commands in the prgm > Hub > Rover (RV)… > RV Color… menu shown to the right.
Send(“SET RV.COLOR 255 255 255”) produces a white light.
Adding RV.COLOR to Your Program
- Add a RV.COLOR command to the loop body immediately before the FORWARD 1 command. The color values are up to you.
- Run the program again to see what happens. Notice that the LED lights up almost immediately and stays on.
Now, let’s try to get the LED to light up only while the Rover is moving FORWARD. This will require that we make the calculator Wait until each segment is completed and then turn the LED off while it is turning.
We need to add a Wait statement to our program to control when the LED is turned on and off.
- How long does it take the Rover to move FORWARD 1? About 1 second? Add a Wait 1 statement after the FORWARD 1 statement. Recall that Wait is found in the prgm > Hub menu.
- Run the program to test it.
Note that the LED still stays on. We have to turn the LED off after the Rover has finished moving.
- How long does it take the Rover to turn? About 1 second? Add a Wait 1 statement.
- After the Wait 1 statement, turn the LED off by adding Send(“SET RV.COLOR 0 0 0”).
- Test your program. Did the Rover turn the light off at the right time?
We also need to wait while the Rover turns to a new heading to make sure the light has turned off.
- Add a Wait statement after the TO ANGLE statement. This Wait should be long enough to handle any turn from 0 to 360 degrees.
Application PolygonsDownload Teacher/Student Docs
The application for this unit is to program the Rover to make a polygon where the user enters the length of a side (in ‘Rover units’) and the number of sides of the polygon. The Rover will then make the polygon.
- Input statements
- Using eval( ) in the Rover instructions
- Understanding polygon principles
- Working with COLOR and timing (Wait)
Recall that the purpose of eval( ) is to convert the value of a calculator variable or expression into a string to be sent to the TI-Innovator™ Hub. In the sound program shown at the right, the user enters a frequency for the variable F. The eval(F) function converts that number into a string representation that the TI-Innovator™ Hub can process.
Write a program that asks for the length of a side and the number of sides of a polygon and moves the Rover in that pattern. You can add a marker to the Rover and actually draw the polygon on a large sheet of paper. Remember that 1 unit is 10 cm.
Optional: Make the COLOR LED light up at the vertices of the polygon.
Some useful commands:
Input “NUMBER OF SIDES?”,N
Send(“RV FORWARD eval(L)”)
- Skill Builder 1
- Skill Builder 2
- Skill Builder 3
Unit 5: Rover's Sensors
Skill Builder 1 Testing Rover's RangerDownload Teacher/Student Docs
In this first lesson for Unit 5, you will learn about the TI-Innovator™ Rover’s Ultrasonic Ranger sensor and its ability to control the Rover’s motion.
- Use the READ RV.RANGER command to measure distance
- Use the command to change the Rover’s motion
At the front of the TI-Innovator™ Rover is a sensor called the Ultrasonic Ranger. The Ranger measures the distance to an object in front of the Rover. This information can be used to control the Rover’s movement; if the Rover gets too close to an obstacle, it can be programmed to change direction to avoid the obstacle.
We’ll first write a test program to determine how the Ranger works and then, in Skill Builder 2, we’ll use that information to control the Rover’s movement.
The program will read the Rover’s Ranger value and display that value on the calculator screen. The Rover will not move in this program. You will move your hand in front of the Rover or hold the Rover in your hands, and point it toward various obstacles to observe the measurements.
Start the Test Program
- Our new program is named ROVER61. It begins with the ClrHome command. Next, add the Send (“CONNECT RV”) command from the prgm > Hub > Rover (RV)… menu.
The Main Loop
We’ll use a While loop to control the program. When the distance measured is less than a certain value, the program will end. We use the variable D to record the distance measured.
- Initialize D to be 1.
- Select While from the prgm > CTL menu. Code the While loop to continue as long as D is greater than 0.1.
The Loop Body
- The command to READ RV.RANGER is found in the
prgm > Hub > Rover (RV)… > Read RV Sensors… menu.
- Select Send(“READ RV.RANGER”).
- Add the commands
to the loop body.
Getting a value from a sensor requires both the Send(“READ…”) command to get a value from the sensor into the TI-Innovator™ Hub and the Get( ) command to get the value from TI-Innovator™ Hub to the calculator. The Wait .25 command is used to slow the operation down to make the numbers easier to read and understand.
Displaying the Value
- We use an Output( ) command to display the value of D in a fixed position on the calculator screen.
- Add the End command.
Run the Program
- While the program is running, the calculator screen displays a number. Move your hand in front of the Rover so that the Ranger can measure various distances. In what units are these distances measured? When will the program terminate?
Answer: The units are meters, and the program will end when the distance measured is less than 0.1 m, or 10 cm.
Skill Builder 2 Ranger and MovementDownload Teacher/Student Docs
In the first lesson of Unit 5, you tested the Rover’s Ranger to see how to read the sensor and display a value. This lesson advances that testing to control the Rover’s motion.
- Use the READ RV.RANGER command to determine the distance to an obstacle
- Control the Rover’s movement when the Rover gets too close to an obstacle
- Manage the timing of the Rover’s movement within the calculator program
Let’s write a program to make the Rover move back and forth between two ‘walls’. We’ll start the Rover moving FORWARD, read the Ranger sensor and, when the Rover gets too close to the wall, make the Rover stop, turn around, and move FORWARD.
The Big Idea
In a For loop (which will eventually terminate)
Start the Rover moving FORWARD
While the distance is greater than about 3 cm
continue to monitor the Ranger sensor
End the While loop
STOP, turn RIGHT 180
End the For loop
- Begin the program in the usual manner.
- Add a For( loop that will iterate ten times.
- Add a FORWARD 100 command to move ahead 10 meters (100 * 0.1m per unit).
- Remember to End the For( loop structure.
As in the previous lesson, we’ll use the variable D to represent distance from the Ranger to an obstacle.
- Initialize D to 1, and start a While D > 0.25 loop.
Note the two Ends in the code; one is the End of the For loop and one is the End of the While loop.
- We next insert the code in the body of the While loop. If you don’t have enough blank lines in your program, place the cursor at the beginning of a line where code is to be inserted. Press [ins] ([2nd] [del]), and then press [enter]. Alternatively, to add a line of code above a current line of code, press [alpha] F5, and select Insert Line Above.
- Add the Send(“READ RV.RANGER”) command.
- Use the Get( command to store the value into the variable D.
That completes the While loop. The Rover is moving FORWARD 10 meters, and the While loop is monitoring the distance. If desired, add an Output( statement to this While loop to display the current distance to make sure things are working properly.
When the While loop ends, this indicates that the Rover is too close to an obstacle. We’ll tell the Rover to STOP moving FORWARD and turn around. However, we do not need to tell the Rover to move FORWARD again.
- After the End of the While loop but before the End of the For loop, add the RV STOP command and then the RV RIGHT 180 command.
- Add the Wait 2 statement to give the Rover time to turn around before moving FORWARD again. (Remember that the FORWARD command is at the beginning of the For loop.)
- Quit, and test your program. When the Rover gets close to an obstacle, it should turn around and go in the opposite direction. Adjust values (minimum distance and Wait time), as needed, for your surface situation. If the Rover gets too close to the wall, then the back of the Rover could bump the wall when turning around.
Skill Builder 3 The COLORINPUT sensorDownload Teacher/Student Docs
In this third lesson of Unit 5, we introduce the COLORINPUT sensor and use its value to cause the Rover to change direction.
- READ COLORINPUT
- Use the value to change the Rover's direction
The Rover has a COLORINPUT sensor on the bottom. The light shining at the floor is used by the sensor to better ‘see’ the color on the floor. We’ll write a program to turn the Rover when it ‘sees’ a change in color. The color seen by the sensor is converted by the TI-Innovator™ Hub into one of nine possible values that represent colors:
1 = Red
2 = Green
3 = Blue
4 = Cyan
5 = Magenta
6 = Yellow
7 = Black
8 = White
9 = Gray
- We’ll use a For loop to cause the Rover to move and turn four times.
- End is the end of the For loop structure.
- We will use a While loop to look for a change in color but first we need to know what color the Rover currently ‘sees’. We READ RV.COLORINPUT, and Get its value into the variable C in the calculator.
- We then initialize another variable, D, to get the While loop started. D will hold the color the Rover sees while it is moving. Initially, we set D to be the same as C. Then, we start the Rover moving FORWARD.
We now code the While loop to compare D with C because, inside the While loop, we’ll look for a change in the value of D.
The ‘equals’ sign is located in the [test] menu ([2nd] [math]).
- Don’t forget to add an End statement for the While loop (not shown).
- Inside the While loop, we monitor the color sensor as long as the Rover is moving. We store the color value in variable D. The loop ends when D (the ‘current’ color) is different from C (the ‘original’ color).
- At the end of the While loop, we tell the Rover to STOP and go RIGHT. Notice that these two statements fall between the two Ends of the program. The second End is the end of the For loop, so the program causes the Rover to turn right four times when it detects a change in the color of the surface.
- Add a FORWARD 1 command and a Wait 1 statement so that the Rover moves away from the colored spot before the program loops back to detect the new ‘original’ color (C) again.
- Test your program on the floor on a surface of uniform color (white). Place an approximately 5 cm by 5 cm contrasting color (black) spot on the floor in the Rover’s path so that the COLORINPUT sensor will see it. When the Rover passes over the spot, it should stop, and then turn and go again. Pick up the color spot, and place it in front or the Rover again. This will have to happen four times for the program to complete.
Application The Winding RoadDownload Teacher/Student Docs
In this application for Unit 5, you will write a program to get the Rover to follow a path on a piece of paper.
- Use COLORINPUT to detect and follow a curved path on paper
- Follow a sample path on paper (See the PDF file of test pages.)
Write a program to get the Rover to follow a curved path on paper using the color sensor. The path will be described by two different colors like this:
The Rover will start at the left edge of the page and travel to the right following the curved path across the paper. When the Rover sees RED, it will turn to the left a little and move forward a little. When the Rover sees WHITE, it will turn to the right a little and move forward a little.
Experiment with the turning angle and the moving distance to see how the Rover reacts to the different colors. If your page is red and white as in the image above, you can use READ COLORINPUT.RED to see what values are given by each side of the paper. If you use a different color such as black, you can use READ COLORINPUT.GRAY (or .GREEN or .BLUE).
Here’s a program (ACOLTEST) you can use to test the Rover’s color sensor. See what values you should use in your program:
Disp "COLORINPUT TEST"
Notice that the Rover does not move in this program. Use the above program to determine what the Rover sees on each side of the wavy line by observing the values of R that are displayed. Use this information to design your program. Test your program by placing the Rover on the left edge of the paper with the color sensor near the border between the red and white sides of the paper. Be sure the Rover’s color sensor is over the paper. Your program should work no matter where the Rover begins.
This program uses an infinite loop. To ‘break’ or terminate a running program is to press the ON key. You will see the error message: ERROR: BREAK at the top of the screen and have the option of 1:Quitting to the HOME screen or 2:Goto the program editor at the point where the action of pressing ON stopped the program.
- Skill Builder 1
- Skill Builder 2
- Skill Builder 3
Unit 6: Coordinates with Rover
Skill Builder 1 Introduction to CoordinatesDownload Teacher/Student Docs
In this first lesson for Unit 6, you will learn about the TI-Innovator Rover’s coordinate system and movement to coordinates.
- Understand the Rover coordinate system and initial position and heading
- Make the Rover move to a certain point on the coordinate plane
- Use mathematics to determine distance
The Rover has a ‘built-in’ coordinate system just like a graphing system. When you Send “CONNECT RV”, the Rover’s position on the coordinate grid is set to (0,0) and its heading is 0 degrees (points toward the positive x-axis).
FORWARD moves the Rover to the right.
LEFT turns the Rover 90 degrees counterclockwise.
Our program will tell the Rover to move to a point on its coordinate grid. We’ll use one Prompt statement to enter values for X and Y and then make the Rover drive to the point (X, Y) and then move back to the origin.
- Start your program with the ClrHome (prgm > I/O > ClrHome) command as well as the usual instructions.
- Include a Prompt statements for X and Y.
Recall that Prompt will display the name of the variable and a question mark. More than one variable can be requested in a Prompt statement.
- The Pause statement gives you time to place the Rover at the origin and face the Rover in the ‘right’ direction.
- Add the Rover command to drive TO XY:
prgm > Hub > Rover (RV)... > Drive RV... > TO XY
The command will appear in your program as an incomplete statement.
- The x- and y-coordinates must be added and will be stored in the variables X and Y, respectively. In order for the TI-Innovator™ Hub to use these values, you must use the eval( ) function twice.
- Add eval(X) eval(Y) to the command, and then add the closing quotation mark and closing parenthesis.
- Test your program now. Depending on the coordinate values you enter, the Rover will move to that position.
- Add a Wait command to let the Rover move to your point, and then tell the Rover to return to the origin. Simply use the numbers 0 and 0 separated by a space. Also, add a statement to make the Rover point in its original direction (TO ANGLE 0).
- Test your program again. This time, the Rover should travel to your entered point and then return to the origin and face in the original direction.
Skill Builder 2 The Distance FormulaDownload Teacher/Student Docs
In this lesson, you will use the TI-Innovator Rover to mark two points on its coordinate plane and determine the distance between the points using the distance formula.
- Move to two different points
- MARK the points with SOUND and COLOR and a marker
- Compute and display the distance between the two points
- Measure the distance between the points to confirm the calculation
- Estimate the error in the movement vs. the computation
This activity requires that a marker be used in the Rover’s marker holder to leave a trail on the paper.
We’ll write a program that marks two points on the plane and computes the distance between the two points. You will then measure the distance between the two points and compare the measurement with the calculation.
- Start your program with CONNECT RV and include the Rover command to set the unit distance to one inch (1 inch ≈ 0.0254 meters). The RV.GRID.M/UNIT command is found in the Rover (RV) > RV Setup menu.
Send “SET(“RV.GRID.M/UNIT .0254”)
- Include four Input statements for the coordinates of the two points. Keep in mind that variables on the TI-84 Plus CE are single letters only.
Note that we use the variables X, Y, Z, and W for the coordinates.
- Next, we get the Rover to move to the first point, Wait while the Rover moves, and then make a SOUND and LED color to indicate that the Rover has reached its point. We will also use a Pause statement here and turn the LED off after pressing enter. Recall that the sound will play for only one second by default.
- Next, we get the Rover to move to the second point. A different sound and different LED color is used to indicate that the Rover has reached the point. A Wait statement is used here to keep the LED on for a few seconds before turning it off.
- Finally, program the calculator to compute and display the distance between the two points using the Distance Formula:
Be careful with the parentheses.
- Measure the second segment drawn (between the two points), and compare that measurement with the computed value. How does the measurement compare with the computed value? What is the percent error of the measurement? (measurement-Distance)/Distance*100
Skill Builder 3 Make the ShapeDownload Teacher/Student Docs
In this lesson, you will write a program to make a pre-designed two-dimensional shape. You will program with lists and use a loop to plot points on paper.
- Define lists and use coordinate pairs stored in lists
- Design a 2-dimensional shape on paper and in the calculator (Stat Plot).
- Have the Rover draw the shape on paper (or simply follow the path).
This project requires the use of two lists that represent the x- and y-coordinates of the vertices of a shape of your own design. In this lesson we will use the design of the block letter T shown to the right. Our goal is to get the Rover to make this design using the marker or just follow the path if no marker is available.
- First, set up two lists containing the coordinate pairs. The lists to the right come from the block letter T shown previously. The x-coordinates are in the list L1 and the y-coordinates are in the list L2. If desired, design a different pattern.
Optional: Set up a Stat Plot to display your data in a graph screen to confirm that your data is correct.
- Now, we can write a program so that the Rover will draw the shape. Start in the usual manner and, optionally, set the M/UNIT value to a smaller value so that the drawing is not too large. Select prgm > Hub > Rover (RV)... > RV Setup... > Send(“SET RV.GRID.M/UNIT.
Remember that 0.01 makes the unit 1 cm. If you want the unit to be 1 inch, use 0.0254. Add the closing quotation mark and closing parenthesis.
- We use a For( loop to process each element of the two lists. Remember that For( requires three arguments, the loop control variable, I, a starting value, 1, and an ending value, dim(L1). Additionally, End is needed at the bottom of the loop body.
Note: dim(L1) is the number of elements in the list L1.
Application Random WalkDownload Teacher/Student Docs
Overview: Explorations with random numbers can lead to fascinating observations. This application gives you opportunities to explore more probability oddities and to program the Rover to move around on a grid.
- Use coordinate movement to simulate a ‘random walk’
- Use counters and accumulators in a program
- Use compound conditions with not and and
A ‘random walk’ is a computer programming experiment. This activity ties together several different programming skills.
Suppose your town’s streets are laid out in a square grid pattern and that your school is located at (0,0) on the grid. Your home is at (7,3), which represents 7 blocks east and 3 blocks north of the school. (Consider changes to this position.) The image to the right is a Stat Plot of these two points.
Starting at the school, you walk one block in a random direction (north, south, east, or west). At each intersection you then walk one block in a random direction again. Will you ever make it home? How many blocks will you walk before getting home? Will you quit from exhaustion before you get home?
Planning is an important part of coding. Think about what the Rover can do and what your programming language can do.
Bear in mind that, when working with random numbers, we are at the mercy of the machine. It may take a long time for the Rover to reach home, so we’ll add a stipulation that the Rover is allowed only a limited number of blocks before quitting.
- Begin this program with the CONNECT.RV statement. Set the Rover’s grid size to 5 cm using Send(“SET RV.GRID.M/UNIT .05”).
Recall that the command is found in prgm > Hub > Rover (RV)... > RV Setup... menu and it changes the Rover’s ‘unit’ of movement (used in FORWARD 1) from 10 cm to 5cm, allowing for more grid points in a smaller space.
- Store the home location (7,3) and the starting number of blocks walked (0) in the variables A, B and W, respectively. The variable W will be used to keep track of the number of blocks the Rover walks and will be used to stop the program if the Rover walks too far. The Rover quits from exhaustion when it walks a specified number of blocks.
Let's use 10 blocks walked as a value for the exhaustion distance. Use the variable E for this value: 10→E.
- The Rover arrives home when its position, which we refer to as (X, Y), is (7, 3). Initialize both of the variables, X and Y, to be zero.
The Main Loop:
- The main loop of the program consists of a While loop with two conditions to be addressed. The conditions are making it home (when X=A and Y=B) or quitting from exhaustion (when W = E). The Rover quits when the variable W (the number of blocks walked) is equal to the value stored in E.
The While loop continues as long as those conditions are false, so we set up the opposite conditions.
The While loop will be:
While W<E and not(X=A and Y=B)
Remember that fixed values related to the problem are stored in E, A, and B.
not( ) is used to ensure that the program continues as long as the Rover is not ‘home’. Logically, and not( is the ‘opposite’ of or.
- Remember to include an End statement for the loop.
Inside the loop:
- Increment W (the number of blocks walked): W+1→W.
- Pick a random direction (north, south, east, or west):
- The Rover’s TO ANGLE command turns the Rover to an ‘absolute’ direction: 0 is east, 90 is north, 180 is west, and 270 is south
- randInt(0,3) gives a random Integer from the set 0, 1, 2, and 3
- Multiply that value by 90 to get 0, 90, 180, or 270
- The statement to pick a random Direction D is:
- Turn the Rover to the Angle D: Send(“RV TO ANGLE eval(D)”).
- Move the Rover forward 1 unit (1 block in our simulation): Send(“RV FORWARD 1”).
- Update the Rover’s position in the program:
- If the Rover goes north, then increase Y by 1
- If the Rover goes east, then increase X by 1
- If the Rover goes south, then decrease Y by 1
- If the Rover goes west, then decrease X by 1
Include some Wait commands to keep the program in sync with the Rover’s movements. Turning takes time and moving forward takes time. The Wait times depend on the angle of the turn and the distance travelled so you may need to experiment with the Wait values.
After the Loop:
The loop ends in one of two ways:
- If W=E, then the Rover quits walking from exhaustion. Play a sad song, display a red color on the Rover’s LED, and display “ROVER QUIT” on the calculator screen.
- If X=A and Y=B, the Rover made it home. Play a happy song, display a green color on the LED, and display a “ROVER MADE IT HOME” message on the calculator screen.
Can you get the Rover to do a ‘happy dance’ when it arrives home?
- Skill Builder 1
- Skill Builder 2
- Skill Builder 3