MicroPython FaceBot
Welcome to the FaceBot Lab
Robots are much more fun when they have faces! In this lab you will draw
simple emoji-style faces on the OLED display on the front of your robot.
You can even give your robot different expressions depending on what it is doing.
Let's build something amazing!
What Is the FaceBot?
The FaceBot is a robot that displays cartoon faces on a small OLED screen mounted at the front. The faces change to show the robot's "mood" or state:
- Happy face — when the robot is driving normally
- Surprised face — when it detects an obstacle
- Sleeping face — when the robot is idle
We are inspired by the expressive faces on robots like Cozmo:
What You Need
| Part | Purpose |
|---|---|
| Maker Pi RP2040 robot | The base robot with motors and controller |
| 128×64 OLED display (I2C) | Shows the face — connect to the Grove I2C port |
ssd1306.py driver |
Library for drawing on the OLED |
Make sure the ssd1306.py driver file is saved on your Pico before running
any code. You can find it in the src/drivers/ folder of this project.
Setting Up the OLED Display
The OLED connects to the I2C Grove port on the Maker Pi RP2040:
| OLED Pin | Maker Pi RP2040 |
|---|---|
| GND | GND |
| VCC | 3.3 V |
| SDA | GP0 (I2C SDA) |
| SCL | GP1 (I2C SCL) |
Drawing a Happy Face
The OLED screen is 128 pixels wide and 64 pixels tall. You draw faces using circles, lines, and filled rectangles.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
Key Idea
oled.fill(0) sets every pixel to black (off). oled.pixel(x, y, 1) turns
one pixel white (on). oled.show() sends the whole drawing to the screen at
once — nothing appears until you call show().
Drawing a Surprised Face
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
Drawing a Sleeping Face
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
Animating the Faces
Put the faces together with motor commands so the robot changes expression based on what it is doing:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
Monty's Tip
Try adding a winking face by drawing only the right eye closed. You can
also use oled.text("HI!", 48, 28, 1) to add a speech bubble with a word
on the screen!
You Can Do This!
Drawing faces with individual pixels takes a bit of patience. If your face
looks wrong at first, try changing the x and y coordinates a little at a time.
That is exactly how game artists work!
Great Work!
Your robot can now show emotions! Try combining the FaceBot code with the
collision avoidance robot so the face automatically changes when the robot
spots an obstacle.
