Back to projects

Spring 2025

Robot vacuum

Context
Microcontrollers, EPFL (bachelor in microengineering), spring 2025
Team
2 students, with Yann Royer
Grade
6/6
Board
STK-300, ATmega128L
Language
AVR assembly

Images

The prototype: STK-300 board with the ATmega128L and the LCD, the two servo-driven wheels and the 8×8 LED matrix

A robot vacuum that sweeps a rectangular room on its own, with all the code written in assembly for an ATmega128L. We were two students, and we built it for the Microcontrollers course at EPFL in spring 2025.

You put it in a corner facing the opposite wall. It drives straight until the infrared sensor sees a wall, then turns around with a sideways offset and starts the next lane. If there is a wall right after the offset, the room is done and it stops. The + and − buttons set the speed, shown on the LCD, and a pause button puts it to sleep. An 8×8 LED matrix shows its state with a face: asleep, happy, surprised or dead.

There is one module per peripheral (servos, IR sensor, buttons, LED matrix, LCD), all included from a main file. The buttons use the external interrupts INT0 to INT2, and the ADC raises an interrupt at the end of each conversion, so the program never waits for the sensor. Each face is 8 bytes in program memory, one bit per pixel, which a routine expands into colours for the 64 WS2812B LEDs.

The wheels are continuous-rotation servos, which need a 1 to 2 ms pulse every 20 ms. We wrote a library that cuts the 20 ms into ten 2 ms slots on a single 8-bit timer. That drives up to ten servos with one timer, with 128 steps over the useful range instead of about 12 with the built-in PWM. The final robot uses a simpler version on the 16-bit timer 1.

For a long time the servos wouldn't change speed even though the signal on the pin looked right. The problem wasn't the code: the STK-300 board couldn't power the servos and rebooted at every speed change. An external supply fixed it.