Lesson 17

App Remote Control (Hiwonder 6.10)

🤖 Second Semester Begins - Remote Control to Vision

🎯 Learning Objectives

📱 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

What You Should See

📲 Section 2.5: Install the Hiwonder Control App

In the Google Play Store, search for Hiwonder. Install the app named Wonderbot (Publisher: Hiwonder).

  1. Open the Google Play Store
  2. Search Hiwonder
  3. Install Wonderbot (Hiwonder • Tools)
  4. Turn on Bluetooth on your phone/tablet
  5. Power on the robot and connect inside the app
Official Instructions: Instructions for how to use the app are in the Hiwonder PDF here: App Remote Control (Hiwonder Docs)

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

📄 Download app_control.ino 📄 Download Ultrasound.h 📄 Download Ultrasound.cpp
Upload Tip: Remove the Bluetooth module before uploading sketches to avoid serial conflicts. Re-install it after upload.

📄 app_control.ino

Loading...

📄 Ultrasound.h

Loading...

📄 Ultrasound.cpp

Loading...

🛠️ 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:

  1. Connect to the robot in the app and verify you can send F/B/L/R/S
  2. Test STOP from every state (moving forward, turning, reversing)
  3. Test timeout safety: stop sending commands and confirm the robot stops automatically
  4. Build a tape course: straight line, 90° turn, reverse into a “parking box”
  5. Record: response time and any failures (missed commands, disconnects)

📝 Assessment & Homework

Lesson 17 Assignments

Programming Challenges:

  1. Command Parser: Add speed commands (0-9) and clamp motor PWM to a safe range
  2. Failsafe: Implement a command timeout that stops motors if connection is lost
  3. Status Feedback: Send back a short status string over serial (e.g., “OK:FWD:S5”)
  4. 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.

← Lesson 16 📚 Second Semester Overview Next: Lesson 18 →