Lesson 17
App Remote Control (Hiwonder 6.10)
🤖 Second Semester Begins - Remote Control to Vision
🎯 Learning Objectives
- Connect miniAuto to a phone/tablet using the official app remote control workflow
- Understand the difference between the app (UI) and the robot firmware (what actually drives motors)
- Practice safe remote driving (speed limiting, emergency stop, connection-loss behavior)
- Learn a clean “command protocol” pattern (single-character commands like F/B/L/R/S)
- Verify and troubleshoot common connection problems (pairing, serial conflicts, power)
📱 Section 1: What “App Control” Really Means
The phone app is just a remote “controller UI”. The robot still needs firmware on the Arduino to:
(1) read incoming commands (Bluetooth/WiFi serial data), and (2) translate those commands into motor actions.
A Simple Command Protocol
// Example command set (keep it small and reliable)
// F = forward
// B = backward
// L = left
// R = right
// S = stop (always supported)
// 0-9 = optional speed presets
//
// The app sends commands.
// Arduino reads them from Serial (or SoftwareSerial).
// Arduino controls motors based on the command.
🔗 Section 2: Connection + Pairing Checklist
Before You Start
- Power: Robot battery is charged and switch is ON
- Bluetooth module: Installed firmly (correct orientation)
- Upload safety: Remove Bluetooth module when uploading sketches (prevents serial conflicts)
- Phone Bluetooth: Enabled, and robot is discoverable/pairable
What You Should See
- Bluetooth LED: Usually blinks fast when not connected, slower/steady when connected
- App status: Shows connected device (or a connect button)
📲 Section 2.5: Install the Hiwonder Control App
In the Google Play Store, search for Hiwonder. Install the app named
Wonderbot (Publisher: Hiwonder).
- Open the Google Play Store
- Search Hiwonder
- Install Wonderbot (Hiwonder • Tools)
- Turn on Bluetooth on your phone/tablet
- Power on the robot and connect inside the app
🧯 Section 3: Arduino Side - Reading Commands Safely
App control is only as safe as your firmware. Your robot should always:
(1) have a STOP command, (2) stop when no commands are received for a timeout, and (3) clamp speed.
Command Handling Pattern
// Pseudocode structure
unsigned long lastCommandMs = 0;
const unsigned long COMMAND_TIMEOUT_MS = 500; // stop if no command for 0.5s
void loop() {
if (Serial.available()) {
char cmd = (char)Serial.read();
lastCommandMs = millis();
handleCommand(cmd);
}
if (millis() - lastCommandMs > COMMAND_TIMEOUT_MS) {
stopMotors();
}
}
void handleCommand(char cmd) {
switch (cmd) {
case 'F': moveForward(); break;
case 'B': moveBackward(); break;
case 'L': turnLeft(); break;
case 'R': turnRight(); break;
case 'S': stopMotors(); break;
}
} 📦 Section 4: Required Code Files
The official Hiwonder app control program uses three files. Download them below and/or copy the code.
Upload Tip: Remove the Bluetooth module before uploading sketches to avoid serial conflicts. Re-install it after upload.
🛠️ Hands-On Activity: Drive Course + Safety Test
Goal
Set up app control, then prove it’s safe and responsive by completing a simple driving course.
Activity Steps:
- Connect to the robot in the app and verify you can send F/B/L/R/S
- Test STOP from every state (moving forward, turning, reversing)
- Test timeout safety: stop sending commands and confirm the robot stops automatically
- Build a tape course: straight line, 90° turn, reverse into a “parking box”
- Record: response time and any failures (missed commands, disconnects)
📝 Assessment & Homework
Lesson 17 Assignments
Programming Challenges:
- Command Parser: Add speed commands (0-9) and clamp motor PWM to a safe range
- Failsafe: Implement a command timeout that stops motors if connection is lost
- Status Feedback: Send back a short status string over serial (e.g., “OK:FWD:S5”)
- Debounce: Ignore repeated identical commands faster than a chosen threshold
Research Assignment:
Research and write a 1-page report on "Why robots need a failsafe when controlled remotely".
Lab Report:
Document your app control test results: connection steps, control mapping, and safety test outcomes.