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:
-
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:
Alternatively if you have already created new project, you can access the SDK Manager by clicking the tiny android icon on the task bar:
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
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:
Make sure your mobile phone/tablet is in debug mode:
Connect your mobile phone/tablet to the computer
Run the app:
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:
Write a mobile app that will rotate robot's engine A three times forward with speed 40.
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.
Write a function called
public void turnRight()
Write a function called
public void turnLeft()
Write a function called
public void forward(int noRotations)
Write a function called
public void backward(int noRotations)
Write a function called
public void turnAround()
Write a function called
public void forward(int centimeters)
Write a function called
public void backward(int centimeters)
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