Free tool online
Line-following robot simulator: circuits, motors and AVR assembly
Build a two-wheel robot, wire its sensors and motor drivers, program its microcontroller in assembly, and watch it follow a line. The circuits, the motors, the wheels and the chip are simulated together in our solver.
Sign in to use the robot lab
The robot lab did not load. Check your connection and try again.
What you can do here
- Build the robot: place the reflectance sensors (position, height, tilt and the spacing of the LED and detector), the wheels, the caster, the motors and the battery on a top view of the chassis, with numbers for every value.
- Wire it: the default robot steers with two comparators that switch the motor transistors, with real part values you can change. Any sensor or motor stage opens in the circuit simulator with its present values.
- Program it: switch to the ATmega328P controller and write AVR assembly. The assembler runs in the page, with the register and bit names of the datasheet, and a debugger shows registers, flags, memory, timers and pins.
- Drive it: an oval, a figure eight, sharp turns, a gap and a crossing line, on matte paper, a glossy board or a grey floor, in a dark room, a daylight room, under a lamp or by a sunny window.
How the robot is simulated
Each half second of driving is one time simulation in our solver: the sensor circuits (LED, phototransistor, comparator), the transistors or the MOSFET H-bridge, the DC gear motors with their back EMF, the wheels with their grip on the floor, the motion of the chassis and the light each sensor gets from the floor under it. With the microcontroller, its program runs instruction by instruction in the same simulation, reading the sensor voltages with its ADC and driving the H-bridge with its timers.
The page asks for the next half second while it shows the present one. If the solver falls behind, the robot slows down and the page says so; it never fills a gap with a guess. Any change you make starts again from the state at that moment.
The default robot
A 6 V pack of four cells, two small 1:48 gear motors on 42 mm wheels 130 mm apart, and two sensors 75 mm ahead of the axle and 12 mm either side of a 19 mm line. On the oval its solved lap takes 7.48 s, and its axle stays within 10 mm of the line.
Lessons and challenges
- Six assembly lessons: blink the LED, read a sensor with the ADC, drive the motors with PWM, bang-bang line following, proportional steering in fixed point, and a lap-time challenge.
- Circuit and design challenges: set the threshold for a glossy track, size the base resistor of the motor transistor, keep working by a sunny window, and space the sensors so the robot moves at all.
Each lesson has a starting point, hints one at a time, and checks that read the simulated run.
What is not simulated
Charge stored in the transistors and diodes (it acts in nanoseconds), sideways sliding of the wheels, and the EEPROM, SPI, TWI and watchdog of the chip. Signed-in users can also write the robot program in C and compile it on the site.