Robot simulator
Program a virtual robot right here, with no kit and no account. It has two motors, two line sensors underneath and three distance sensors (front, left and right), like a typical Arduino robot car.
Robot commands
motors(left, right): wheel power, −100 to 100lineLeft(),lineRight():trueover the black linedistance(): cm to the nearest thing ahead (max 200)distanceLeft(),distanceRight(): cm to the sideslinePosition(): where the line is, −1 (left) to 1 (right), ornullmillis(): milliseconds since Runprint(value): show a message belowsetup()runs once;loop()runs 50 times a second
How to use it
- Pick an arena. Each one loads starter code.
- Press ▶ Run and watch what the robot does.
- Change the code, then Run again. Use ↺ Reset to put the robot back at the start.
Your code works like an Arduino sketch: setup() runs once, then loop() runs 50 times per second. Each time, read the sensors and set the motors. That’s the sense, think, act loop.
Challenges
| Arena | Challenge |
|---|---|
| Line track | Make the robot complete a lap faster. How high can you push the speed before it loses the line? |
| Line track | Use millis() to stop the robot after exactly 10 seconds. |
| Obstacle room | Turn towards whichever side has more space (distanceLeft() vs distanceRight()). |
| Obstacle room | Slow down smoothly as you get closer to a wall instead of stopping suddenly. |
| Maze | Reach the green goal. Try the right-hand rule: keep a wall close on your right. |