Skip to content
RoboLearn

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 playground

Robot commands
  • motors(left, right): wheel power, −100 to 100
  • lineLeft(), lineRight(): true over the black line
  • distance(): cm to the nearest thing ahead (max 200)
  • distanceLeft(), distanceRight(): cm to the sides
  • linePosition(): where the line is, −1 (left) to 1 (right), or null
  • millis(): milliseconds since Run
  • print(value): show a message below
  • setup() runs once; loop() runs 50 times a second

How to use it

  1. Pick an arena. Each one loads starter code.
  2. Press ▶ Run and watch what the robot does.
  3. 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.