1 · Drive to the loop
Drive the pretend car through the gap in the wall to the black loop.
Connecting to simulator…
Start the bridge on the laptop connected to the car’s Wi-Fi. Setup instructions
3 m × 2 m · Black tape · Brown walls · Dashed ultrasonic beam
{"N":100}Hold to drive. Release to stop. Use arrow keys, WASD, or a gamepad.
Delay applies only to simulator movement. STOP cancels queued moves immediately. Real Mars delays take minutes; this model keeps the view live.
Steps run in order. Speed comes from the Top speed slider.
Distance ahead
Line sensors (dark = on the tape)
→ Sent to car · ← Received from car
Code studio
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.
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.
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.
Drive the pretend car through the gap in the wall to the black loop.
Park it on the black line. Press Follow line. Bolt drives around the loop by itself!
Choose the Dance example and press Run mission. Then change a step and run it again.
Tap ▲ once. Find the message in the log. Which number changed when you moved the speed slider? Which stayed the same?
Set Simulator command delay to 3 s and drive through the wall gap. Why is it so hard? How would you drive differently?
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
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.
Explorer · Story time
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!
Meet the car
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.
Runs ELEGOO's factory program. It reads JSON messages at 9600 baud and acts on them.
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.
An ultrasonic sensor on the head measures distance with echoes. Three infrared line sensors look at the floor. A gyro keeps it driving straight.
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
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.
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.
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
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.
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.
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.
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.
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
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.
| Message | What it does | Car 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
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.
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.
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.
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 }.
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.
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
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.
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.
Weave through five cups placed 40 cm apart and back. Every cup knocked over adds 5 seconds.
Drive one lap of a black-tape loop by hand, then press Follow line. Who's faster? Who stays on the line better?
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.
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
For the teacher
ELEGOO BT16), and press Pair.An HC-05 module (“classic” Bluetooth) won't appear. Web Bluetooth only sees BLE.
ELEGOO- plus a code.node scripts/robot-car-bridge.mjs
http://localhost:8787. The bridge serves this page and connects by itself.Practice first with --mock: a simulated car answers, no robot needed.
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>.
ws://localhost. Chrome may ask to allow local network access. Choose Allow.Model & evidence
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
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?