Robot Car Pilot

Connecting to simulator…

Bridge

Start the bridge on the laptop connected to the car’s Wi-Fi. Setup instructions

Simulator room

3 m × 2 m · Black tape · Brown walls · Dashed ultrasonic beam

Last command{"N":100}

Controls

Hold to drive. Release to stop. Use arrow keys, WASD, or a gamepad.

Code studio

Program the car with blocks

Drag blocks from the menu on the left and snap them under when ▶ Run is pressed. The program runs on whatever the cockpit is connected to: the simulator or the real car.

Loading the block editor…

Loading…

Speeds above the cockpit’s Top speed (180) are cut to it. Programs stop themselves after 2 minutes. Stop, Space and Esc stop them at once.

Variables

Output (the show block)

 
The same program in Arduino C++

This is your program written as a sketch for the car’s own Arduino UNO, so it runs with no computer at all. Uploading it replaces ELEGOO’s factory program: Bluetooth, Wi-Fi, the app and this cockpit stop working until you upload the factory sketch again from ELEGOO’s download for the kit. Upload with the Arduino IDE (board: Arduino Uno). Slide the shield’s switch to “upload” first and back after. Programs with a light block need the FastLED library. The pin numbers come from ELEGOO’s V4.0 code; try each new sketch with the wheels off the ground.

One difference to look for: in your own sketch, reading a line sensor does not stop the motors. The factory program does stop them, so the live version sends the drive again after each reading.

 

Try the cockpit

Start with the Simulator, the pretend car on the screen. Hold an arrow or drag the yellow knob. Let go to stop. When it's your turn with the real car, your teacher will press Bluetooth or Wi-Fi.

Pick a connection. The simulator runs the same commands as the real car, so everyone can practice while one team drives. Drive with the joystick, the arrow buttons, W A S D or arrow keys, or a USB/Bluetooth gamepad. Space or the red button stops. Watch Last command under the view to see the exact message just sent.

The simulator room is 3 m × 2 m. The black loop is tape, the brown blocks are walls, and the dashed line shows the ultrasonic beam. The beam turns red when an obstacle is within 20 cm.

1 · Drive to the loop

Drive the pretend car through the gap in the wall to the black loop.

2 · Let it drive

Park it on the black line. Press Follow line. Bolt drives around the loop by itself!

3 · Make it dance

Choose the Dance example and press Run mission. Then change a step and run it again.

1 · Read the log

Tap ▲ once. Find the message in the log. Which number changed when you moved the speed slider? Which stayed the same?

2 · Feel the delay

Set Simulator command delay to 3 s and drive through the wall gap. Why is it so hard? How would you drive differently?

3 · Program a square

Load Square. Tune the spin times until the car ends up where it started. Will the same times work on the real car?

Engineering · Robotics · Teleoperation

Pilot the Robot Car From a Browser

Our robot car can't hear you. It only understands short typed messages. This page sends those messages for you. Push the joystick and the car rolls. Let go and it stops. Practice on the pretend car first, then take turns driving the real one!

Driving a robot from far away is called teleoperation. People use it to steer underwater robots. Mars missions need more autonomy because messages take minutes to arrive. This page is a remote control for the class's ELEGOO Smart Robot Car V4.0. It connects over Bluetooth or Wi-Fi and sends the same short JSON messages the official app sends. It also shows every message, so you can learn the robot's language.

Ages 6–18 · 3 levels30–90 minutesReal robot + simulatorBluetooth · Wi-Fi · USB
← Back to Engineering
A laptop on the left sends curly-brace messages through radio waves to a yellow four-wheeled robot car on the right {"N":3, "D1":3} message → radio → robot → motors

Explorer · Story time

I only understand messages

I'm Bolt! I have four wheels, two eyes that hear echoes, and a little brain called an Arduino.

I can't hear your voice. When you push the joystick, the computer sends me a tiny message, like “go forward, medium fast.” I read it and spin my wheels.

When you let go, the computer sends “stop.” The Wi-Fi bridge can stop me when driving messages stop. Other connections need different safeguards. Keep a grown-up near my power switch!

  • Pilot · the person who drives
  • Message · a short note sent to the robot
  • Signal · how the note travels through the air
  • Sensor · a part that helps the robot notice things

Play “Human Robot Car” first

  1. Make message cards. Write FORWARD, BACK, LEFT, RIGHT, and STOP on cards.
  2. One robot, one pilot. The robot walks only when the pilot holds up a card. No talking! The robot does exactly what the card says.
  3. Steer through a course. Guide the robot around two chairs to a goal. What happens when the pilot is slow to show STOP?

Meet the car

What's on the ELEGOO V4.0

Our car has a brain, wheels, eyes, and a camera. The brain reads the messages. The other parts do the work.

The car is a stack of modules, each with one job. Every command you send ends up at the same place: the Arduino UNO's serial port. The UNO decodes it and drives the motors, servo, or light, or reads a sensor and sends back an answer.

Brain: Arduino UNO

Runs ELEGOO's factory program. It reads JSON messages at 9600 baud and acts on them.

Muscles

Four DC motors in two sides (left and right), run by a TB6612 motor driver. Speed is a PWM number from 0 to 255.

A servo motor turns the “head” left and right.

Senses

An ultrasonic sensor on the head measures distance with echoes. Three infrared line sensors look at the floor. A gyro keeps it driving straight.

Radios

The ESP32 camera board makes its own Wi-Fi network and streams video. Some kits also have a Bluetooth Low Energy module plugged into the shield.

Start here · 10-minute flight school

Predict. Drive. Explain.

1 · Get your bearings

The simulator connects automatically. The car starts at x = 40 cm, y = 100 cm, facing right. Hold ▲ briefly, release, then press STOP. “Forward” means toward the car’s blue nose, not up the screen.

2 · Change one thing

Predict: will doubling speed double distance? Reset. Make a mission with just Forward for 0.5 s. Run at speed 100, note “from start,” then reset and repeat at 200. Keep duration and delay unchanged.

3 · Defend your result

Record speed, duration, distance, and one explanation. This ideal model is approximately proportional. Real motors have friction, battery changes, and wheel slip. Test the real car on a clear floor with a spotter and a ruler.

Crew roles: pilot holds controls; spotter watches the route and power switch; recorder notes evidence. Rotate each run. Before hardware driving, test STOP with wheels raised on a stable stand.

Return to the cockpit ↑

How it connects

Four ways to reach the car

The message can fly through the air by Bluetooth or Wi-Fi, or go down a USB cable. All roads lead to the same brain.

Every path delivers the same text to the UNO's serial port. The differences are range, setup, and which browsers can do it.

Bluetooth

Needs: a kit with the ELEGOO BLE module (BT16/HM-10 style), and Chrome or Edge on a laptop, Chromebook, or Android.

The page talks to the module directly with Web Bluetooth. No extra software. iPhones and iPads can't do this.

Wi-Fi

Needs: a laptop on the car's ELEGOO-xxxx network running the bridge program.

Gives you the live camera. Web pages can't open the plain network socket the car uses, so the bridge passes messages through.

USB cable

Needs: Chrome or Edge, the car's USB cable, and the car on a box with its wheels in the air.

Good for testing commands at your desk. Unplug the camera board's cable if replies look scrambled.

Simulator

Needs: nothing.

Runs the same commands on a pretend car. Twenty students can practice while one team drives the real car.

The robot's language

One message, start to finish

The car speaks a small communication protocol written in JSON. N picks the command, D1–D4 and T are its settings, and H is a tag. The car puts that tag in its answer, so the page knows which question an answer belongs to.

The path of one command: the browser page, then Bluetooth straight to the BLE module, or Wi-Fi via the bridge and the ESP32 camera board, then serial at 9600 baud to the Arduino UNO, which drives the motor driver and motors Browser page Bridge (laptop) ESP32 camera BLE module Arduino UNO Motor driver+ motors WebSocketTCP :100serial Web Bluetoothserial 9600PWM
Commands this page uses
MessageWhat it doesCar answers
{"H":"7","N":3,"D1":3,"D2":150}Drive. D1: 1 spin left, 2 spin right, 3 forward, 4 back. D2: speed 0–255. Keeps going until the next command.{7_ok}
{"N":2,"D1":3,"D2":150,"T":800}Same, but stops by itself after T milliseconds.—
{"N":4,"D1":200,"D2":80}Each side at its own speed, for curves. (D1 is the right side. See the deep dive.){H_ok}
{"N":100}Stop everything and wait.{ok}
{"N":5,"D1":1,"D2":90}Turn the head servo to 90°.{H_ok}
{"N":8,"D1":0,"D2":0,"D3":255,"D4":0}Light colour (red, green, blue).{H_ok}
{"N":21,"D1":2}How far is the wall? (ultrasonic){H_43} = 43 cm
{"N":22,"D1":0}Line sensor reading (0 left, 1 middle, 2 right).{H_612}
{"N":101,"D1":1}Drive itself: 1 follow line, 2 avoid walls, 3 follow.{ok}

Engineer deep dive

Safety, timing, and a bug in the factory codeAges 13+

Dead man's switch

A drive command keeps the car moving until something replaces it. If the laptop crashes mid-drive, the car keeps going. So the page repeats the drive command every 250 ms while you hold a control. The bridge sends {"N":100} if a full second goes by with none. This is a software dead man's switch, like the pedal a train driver must keep pressed.

Heartbeat

The ESP32 sends {Heartbeat} every second and expects one back. After about three missed beats it hangs up and stops the car. It also stops the car when no device is on its Wi-Fi. That's a heartbeat signal: silence means trouble.

Why a bridge?

The car listens on raw TCP port 100. For security, web pages may only use HTTP, WebSockets, WebRTC, and a few others, never raw sockets. The bridge is about 300 lines of Node: a WebSocket server on one side and a TCP client on the other. Read scripts/robot-car-bridge.mjs.

Bandwidth

9600 baud with 10 bits per byte is 960 bytes/s. A drive message is about 32 bytes, so four a second uses about 13% of the link. BLE modules accept 20 bytes per packet, so the page splits each message into two writes. The UNO waits for the closing }.

Left is right

In the firmware, N:4 calls its first value “L”. But it sends it to motor group A, which the driver code labels Right. Test it on blocks: send {"N":4,"D1":200,"D2":0} and see which wheels spin. Engineers trust tests over labels.

Reading pauses driving

Asking for a line sensor value (N:22) switches the firmware into “programming mode”. That stops line-following and any drive command. The page reads line sensors only while parked. The ultrasonic read (N:21) doesn't have this problem. Could you fix it in ApplicationFunctionSet_xxx0.cpp?

Challenges

Pilot's license

Do these in the simulator first, then on the floor with the real car. Use tape and cardboard to build the course.

Build a floor course with masking tape, black electrical tape, and cardboard walls. Each team practices in the simulator, then gets a timed run on the real car.

Parking garage

Turn on Read sensors. Park nose-in to a wall as close as you can without touching. Aim for a teacher-marked 20 cm clearance. Score the difference from 20 cm; touching the wall ends the run. The sensor is an estimate, not a collision guarantee.

Slalom

Weave through five cups placed 40 cm apart and back. Every cup knocked over adds 5 seconds.

Human vs. robot

Drive one lap of a black-tape loop by hand, then press Follow line. Who's faster? Who stays on the line better?

Mars mode

In the simulator, set the 3 s command delay. Plan a short move, wait for it to arrive, then observe before sending another. STOP bypasses this teaching delay. Mars rovers use planned commands and onboard autonomy; this is a scaled analogy.

Blind mission

Write a mission program that leaves the start box, goes around a cone, and returns. You get one run with no touching the controls.

Robot autonomy series

Sense · Think · Act

For the teacher

Setting up the real car

Bluetooth

  1. Plug the ELEGOO Bluetooth module into the shield. Turn the car on. The module's light blinks.
  2. Open this page in Chrome or Edge. Don't pair it in the computer's settings.
  3. Press Bluetooth, pick the car (often named ELEGOO BT16), and press Pair.
  4. Label each car and module with a number so teams pick the right one.

An HC-05 module (“classic” Bluetooth) won't appear. Web Bluetooth only sees BLE.

Wi-Fi

  1. Turn the car on. Its camera board makes a Wi-Fi network named ELEGOO- plus a code.
  2. On a laptop with this repo and Node.js, run:
    node scripts/robot-car-bridge.mjs
  3. Join the laptop to the car's Wi-Fi. (The laptop loses internet. That's expected.)
  4. Open http://localhost:8787. The bridge serves this page and connects by itself.

Practice first with --mock: a simulated car answers, no robot needed.

Tablets & many cars

Each car has its own Wi-Fi, so pair one laptop with one car. To drive from a tablet, run the bridge with --lan on a laptop on the car's Wi-Fi. Then open http://<laptop-ip>:8787 on the tablet. Only one pilot drives each car at a time. A second device is turned away.

If you reflash the camera board onto the school Wi-Fi, use --car <its address>.

Safety & troubleshooting

  • Drive on the floor, away from stairs and table edges. Start with Top speed at 150 or less.
  • The page attempts STOP when it loses focus or becomes hidden. The bridge also has a watchdog. A frozen browser or broken BLE/USB link may prevent STOP from arriving: keep a spotter at the power switch.
  • Car ignores commands? Check the shield's upload switch isn't on “upload”, and charge the batteries. Low batteries cause odd resets.
  • The page on the class site (https) can reach ws://localhost. Chrome may ask to allow local network access. Choose Allow.

Model & evidence

What practice can tell you

The simulator accepts the same command format, but its motion, line following, obstacle avoidance, and distance readings are simplified teaching models. It has ideal wheels, a flat room, and a single echo ray; it does not model battery sag, noisy echoes, or real firmware timing. A successful simulated mission does not certify a real car.

Speed 150 is a PWM setting, not 150 cm/s. A timed square is an open-loop program: it never checks whether a corner really reached 90°. Use the position readout to measure the final error, then explain how sensor feedback could improve it.

Space connection: NASA describes Ingenuity as an autonomous aircraft; NASA’s communication-delay analysis explains why Mars operations need autonomy. Hardware compatibility and stopping behavior must be checked on the classroom’s exact kit and firmware.

Quick check

Lock it in

1. How does the robot car know what to do?

2. What happens when you let go of the joystick?

3. Which part tells the car how far away a wall is?

1. What does {"N":3,"D1":3,"D2":150} tell the car?

2. Why does each message carry an H tag?

3. Why does the page keep re-sending the drive command while you hold a control?

4. Why does Wi-Fi driving need the bridge program?

5. At 9600 baud (10 bits per byte), what share of the link do four 32-byte drive messages per second use?