Getting Started With the Project



Download 16.18 Kb.
Date29.07.2017
Size16.18 Kb.
#24451
5/29/2013

Developed by Nannette P. Napier

Note: Instructions adapted from Chapter 12 of Wolber’s App Inventor book, pp. 188-89, http://cs.usfca.edu/~wolber/appinventor/bookSplits/ch12RobotRemote.pdf



c:\users\dave parker\pictures\down sampled\9797 bot steps 736\dcp_4607.jpg

GGC Tech Camp

App Inventor Remote Control






Part 1 Lab Instructions: Personalize Your App’s User Interface


Overview

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 by doing the following:

  • Importing the program into your account

  • 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

  • Go to appinventor.mit.edu. Select “Invent”.

  • Login to App Inventor using the provided Gmail account and password.

  • On the “My Projects” screen, go to “More Actions”  “Upload Source”

  • Select “Choose file”

    1. On your thumb drive, you will have a file under “LEGO Remote Control” called Remote_Starter.zip

    2. Click “OK”. This project should now be imported

  • 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

    1. Change Background Color from White to something else

    2. 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:

    1. Under Media, select Add…

    2. Select the “Choose File” button.

    3. Locate the stop sign file you downloaded and select OK

  • Select StopButton in the Components Viewer (it’s under VerticalArrangement1  HorizontalArrangement1)

  • Under Properties

    1. Change Image from None… to the Stop Sign image you added

    2. 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


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).

1. Open the Blocks Editor. Draw the blocks below:



2. Create APK file

On your computer, in App Inventor


Back in the Component Designer, select Package For Phone | Download to this Computer:

http://docs.google.com/file?id=a8vwpp42j9g_92xccwsk6n_b

Once completed, you’ll get a message like the following, and there will be a new file in your downloads folder.



Copy the Remote_Starter.apk from your Downloads folder to your thumb drive

Safely eject your thumb drive

Hand this to the Student Assistant who will transfer this to an Android tablet for you to use.



3. 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 can run your 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.”

  1. If you see “Paired Device” next to your robot’s name, you’re finished! Otherwise, continue to step 9.

  2. If you see “Pair with this device” under your robot’s name, click it.

  3. On the NXT, it should ask for a passkey. Press the orange square to accept 1234.

  4. On the Android, it should ask for the PIN. Enter 1234 and press OK.

  5. You should now see “Paired Device.” You’re finished!

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.

Download 16.18 Kb.

Share with your friends:




The database is protected by copyright ©ininet.org 2024
send message

    Main page