User Tools

Site Tools


did:roboclub:lab6

Mindroid -- controlling NXT with mobile phone

Setup

You have basic skills in Java programming. Programming for Android is based on Java, but you need to setup Android Development Toolkit. The installation process may take some time, so make yourself a coffee/tea. Here are the steps to follow:

  1. Download and install Android Studio
  2. Open Android Studio and open SDK manager (this is the place where you can manage different versions of SDKs) by clicking Configure button and choosing SDK Manager from dropdown menu:
  3. Alternatively if you have already created new project, you can access the SDK Manager by clicking the tiny android icon on the task bar:
  4. Make sure you have all API levels installed from API 14 until the highest. Select the checkbox next to ever API level and click Apply. It will download and install all required software. It may take more than 1 hour, depending on your Internet connection:

Pulling project stub from repo

To get the project form Github, clone the following link: Project repository. Use the tutorial fr cloning: Cloning repository

Running first program

To run the Mindroid app, you need to have your device paired with NXT robot. All devices you have got had been paired with all the NXT bricks, so you do not need to do this. However, you need to tell the system to which brick you want to connect to, by changing the following variable to store a name of your robot (change YODA to your robot name).

 private static final String ROBOT_NAME = "YODA";

After you have doe this:

  1. Make sure your mobile phone/tablet is in debug mode:
  2. Connect your mobile phone/tablet to the computer
  3. Run the app:
  4. Choose your mobile phone/tablet from the list:

Exercises

Read the tutorial for beginners for Mindroid

Warm up

To complete these exercises you need to write your code in

public void commandProgram()

You can find it in RobotControl class:

  1. Write a mobile app that will rotate robot's engine A three times forward with speed 40.
  2. Write a mobile app that will rotate all of the robot's engines 1 time forward, with speed 10 simultaneously.

More advanced

For the following exercises it would be perfect to have a robot built.

  1. Write a function called
     public void turnRight()
  2. Write a function called
     public void turnLeft()
  3. Write a function called
     public void forward(int noRotations)
  4. Write a function called
     public void backward(int noRotations)
  5. Write a function called
     public void turnAround()
  6. Write a function called
     public void forward(int centimeters)
  7. Write a function called
     public void backward(int centimeters)
  8. Advanced: add buttons to mobile app so that pressing the button will call different functions. This will be kind of remote control for robot. See this tutorial on how to add a button and handle different touch events: Android buttons and touch events
did/roboclub/lab6.txt · Last modified: 2024/10/10 09:22 by 127.0.0.1