A I R C

advertisement
10/14/2012
ITEC
1001
APP INVENTOR REMOTE CONTROL
Lab Activity for ITEC 1001 | Developed by Nannette P. Napier
Instructor Info
Group Lab Setup
Students will work in a group of three
Account ID
Password
GTC2011.01@gmail.com
GTC2011.02@gmail.com
GTC2011.03@gmail.com
GTC2011.04@gmail.com
GTC2011.05@gmail.com
GTC2011.06@gmail.com
GTC2011.07@gmail.com
GTC2011.08@gmail.com
techcamp
techcamp
techcamp
techcamp
techcamp
techcamp
techcamp
techcamp
Associated
Galaxy Tab
Associated Robot ID
To setup for a class,
-
Upload the Remote_Starter.zip project into each Gmail account
1.
2.
-
For 10/15 – completed for 01, 02, 03, 04, 05, 06, 07, 08. Should be ready for the first section.
In between sections, I will need to rest all these accounts
On each Galaxy Tab, make sure the Google account is signed in. While this is not absolutely essential to do
beforehand, it will cut down on the confusion for students.
Sample Lesson Plan (1 hour 40 minutes)
Students will work in a group of three. Start forming groups as students come in. The first thing they’ll do is building the
Express Bot, http://www.nxtprograms.com/9797/express-bot/steps.html .
Duration Description
(min)
20
Building the Express Bot using the basic instructions
15
Educational overview of NXT
- Hardware Overview of NXT system (http://www.nxttutorial.stemcentric.com/Hardware%20Overview.html)
- Emphasizing ITEC 1001 concepts: ports, input device, output devices
Motivation/Fun with NXT
- http://www.youtube.com/watch?v=AToVUoZyWWk Or choose other favorite
15
Overview of App Inventor concepts
- Remote control overview
- Give out Instructions Part 1
50
Lab time
- Part 1 (no new concepts)
- Part 2
Time left
(Plan for 100 min)
80
65
50
Part 1 Lab Instructions: Personalize Your App’s User Interface
You will be making a Remote Control App for a LEGO robot. A picture of the user interface is below and
includes simple commands to move forward (^), backward (v), left (>), and right (<). To stop, you will press the
middle button (-).
To make it easier for you to get started, we have drawn the buttons for you and arranged them on the screen.
In part 1 of this lab, you will personalize the user interface for your group:
-
Change the title and background color on the screen
Find better graphics for the stop button
Play music when the robot connection is successfully made
Getting Started With the Project

Login to App Inventor using the provided Gmail account and password

Under My Projects, select the Remote_Starter project. The designer will look something like the
following
Changing the Screen1 Properties

Select Screen1 in the Components Viewer

Under Properties
a. Change Background Color from White to something else
b. Change the Title from Screen1 to the names of each person on your team
Changing the Stop Button

Search for a picture of a Stop sign on the Web.

Download this file to your desktop.

In App Inventor, upload this file by doing the
following:
a. Under Media, select Add…
b. Select the “Choose File” button.
c. Locate the stop sign file you downloaded
and select OK

Select StopButton in the Components Viewer (it’s
under VerticalArrangement1 
HorizontalArrangement1)

Under Properties
a. Change Image from None… to the Stop Sign
image you added
b. Remove the dash from the Text
Playing Music When the robot connection is successfully made
1. Open the Blocks Editor
2. Under “My Blocks”, select Sound1
3. Drag over the “Call Sound1.Play” purple block and place it in underneath the “Successful connection”
alert message as shown below
Follow the instructions for How to Transfer your App to Android Device – Barcode Method. [End of Part1]
Part 2 Lab Instructions: Driving the NXT
The NxtDrive component provides five blocks for driving the robot’s motors:





MoveForwardIndefinitely drives both motors forward.
MoveBackwardIndefinitely drives both motors backward.
TurnCounterClockwiseIndefinitely turns the robot to the left by driving the right motor forward and
the left motor backward.
TurnClockwiseIndefinitely turns the robot to the right by driving the left motor forward and the right
motor backward.
Stop stops both motors.
The Move… and Turn… blocks each have a parameter called Power. You’ll use a number block to specify the
amount of power the robot should use to turn the motors. The value can range from 0 to 100. However, if you
specify too little power, the motors will make a whining sound but not turn. In this application, you’ll use 90
(percent).
Your turn:
1. Open the Blocks Editor. Draw the blocks on the next page.
2. Connect your LEGO Mindstorms NXT to the Android device by following the instructions for How to
Connect your Android device to LEGO Mindstorm NXT.
3. Download your app to the Android device by following the instructions for How to Transfer your App
to Android Device – Barcode Method.
4. Run your app. Did all the buttons work?
Troubleshooting: Do your left and right buttons seem to be backwards? If so:
In the Designer, the DriveMotors property of NxtDrive1 assume the robot’s left wheel motor is connected
to output port C and the right wheel’s motor is connected to output port B. Switch this around on your bot
if necessary.
[End of Part2]
How to Connect your Android device to LEGO Mindstorm NXT
Both you’re the Galaxy Tab and LEGO Mindstorm NXT are Bluetooth-enabled devices. This means they can
communicate wirelessly once you establish a connection between them. For security reasons, Bluetooth
devices must be paired before they can connect to each other. Before you get started building the app, you’ll
need to pair your Android with your NXT by following these steps:
1. On the NXT, click the right arrow until it says Bluetooth and then press the orange square.
2. Click the right arrow until it says Visibility and then press the orange square.
3. 3. If the Visibility value is already Visible, continue to step 4. If not, click the left or right arrow to set
the value to Visible.
4. On the Android, go to Settings→Wireless & Networks.
5. Make sure the Bluetooth checkbox is checked.
6. Click “Bluetooth settings” and “Scan for devices.”
7. Under “Bluetooth devices,” look for a device named “NXT.”
Note. If you’ve ever changed your robot’s name, look for a device name that matches your robot’s
name instead of “NXT.”
8. If you see “Paired Device” next to your robot’s name, you’re finished! Otherwise, continue to step 9.
9. If you see “Pair with this device” under your robot’s name, click it.
10. On the NXT, it should ask for a passkey. Press the orange square to accept 1234.
11. On the Android, it should ask for the PIN. Enter 1234 and press OK.
12. You should now see “Paired Device.” You’re finished!
Note: Instructions from Chapter 12 of Wolber’s App Inventor book, pp. 188-89,
http://cs.usfca.edu/~wolber/appinventor/bookSplits/ch12RobotRemote.pdf
How to Transfer your App to Android Device – Barcode Method
For this method to work, you MUST have
-
A Google account setup on the Android Device
This Google account is the same one that you used to build in App Inventor
On your computer, in App Inventor
Back in the Component Designer, select Package For Phone | Show Barcode:
After several minutes, a barcode will appear on the screen (Be Patient):
On your Android Device:
Run the QR Droid barcode program on your phone.
Place it over the barcode. On most devices, this will automatically start a download of the app onto the device.
After you get a notification that the download is complete, click on the file name. Follow the prompts to install
and open the app.
Sample Code: Playing a tone on Robot
Valid range for sounds 200 to 14,000 Hz
4000 Ms = 4 seconds
NOTE FREQUENCIES (Hz)
Octave
3
4
5
6
Note
1
2
7
8
9
A
27.5
55.0
110.0
220.0
440.0
880.0
1760.0
3520.0
7040.0
A#/Bb 29.1
58.3
116.5
233.1
466.2
932.4
1864.7
3729.4
7458.9
B
30.9
61.7
123.5
247.0
493.9
987.8
1975.7
3951.3
7902.7
C
32.7
65.4
130.8
261.6
523.3
1046.6
2093.2
4186.5
8372.9
C#/Db 34.6
69.3
138.6
277.2
554.4
1108.8
2217.7
4435.5
8871.1
36.7
73.4
146.8
293.7
587.4
1174.8
2349.7
4699.5
9398.9
D#/Eb 38.9
77.8
155.6
311.2
622.4
1244.8
2489.5
4979.1
9958.1
E
41.2
82.4
164.9
329.7
659.4
1318.8
2637.7
5275.3
10550.6
F
43.7
87.3
174.7
349.3
698.7
1397.3
2794.6
5589.2
11178.4
F#/Gb 46.2
92.5
185.1
370.1
740.2
1480.4
2960.8
5921.8
11843.5
49.0
98.0
196.1
392.1
784.3
1568.2
3137.1
6274.1
12548.2
103.9
207.7
415.5
830.9
1661.9
3323.7
6647.4
13294.8
D
G
G#/Ab 51.9
From http://lizarum.com/assignments/physical_computing/2007/labs/lookup.html
Download