====== 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: - Download and install [[https://developer.android.com/studio/index.html|Android Studio]] - 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:{{:did:roboclub:sdk-manager-open.png|}} - **Alternatively** if you have already created new project, you can access the SDK Manager by clicking the tiny android icon on the task bar: {{ :did:roboclub:sdk-manager.png|}} - 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:{{:did:roboclub:api-install.png|}} ===== Pulling project stub from repo ===== To get the project form Github, clone the following link: [[https://github.com/sbobek/mindroid| Project repository]]. **Use the tutorial fr cloning: ** [[did:roboclub:github_tutorials: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: - Make sure your mobile phone/tablet is in debug mode: \\ {{:did:roboclub:debug-mode.png?200|}} - Connect your mobile phone/tablet to the computer - Run the app: \\ {{:did:roboclub:run-app.png|}} - Choose your mobile phone/tablet from the list: \\ {{:did:roboclub:select-device.png|}} ===== Exercises ===== Read the tutorial for beginners for [[https://sbobek.github.io/mindroid/|Mindroid]] ==== Warm up ==== To complete these exercises you need to write your code in public void commandProgram() You can find it in ''RobotControl'' class: \\ {{ :did:roboclub:commandprogram.png|}} - 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_tutorials:buttons|Android buttons and touch events]]