Robot That Draws Your Face | Kids Robotics Project

Robot That Draws Your Face | Kids Robotics Project | MakeMindz
⭐ STEM PROJECT
Kids Robotics Project

Build a Robot That
Draws Your Face!

⏱️ 3–4 Hours 🔧 Difficulty: Medium 🎓 Age 12+ 💰 ~₹3,500

🔍 How Does It Work?

This robot combines a camera, a tiny computer, and a servo-powered drawing arm into one amazing machine. Here's the magic flow:

1
📸
Snap a Selfie

Pi Camera captures your face photo

2
🖥️
Process Image

Python converts the photo into pencil-sketch lines

3
📐
Plan the Path

Code turns sketch lines into robot arm movements (G-code)

4
✏️
Draw!

Servo motors move the pen and sketch your portrait

🧠 Fun Fact! This is the same technology that big companies use to make robot artists! Professional drawing robots have sketched portraits at museums and exhibitions around the world.
✦ ✦ ✦

🛒 What You'll Need

Gather these parts before you start. Most are available online or at your local electronics shop.

🍓
Raspberry Pi 4 (2GB+) The brain of the robot. Runs Python code.
📷
Raspberry Pi Camera v2 Captures the selfie photo.
⚙️
3× MG996R Servo Motors Move the robot arm (X, Y, Z axes).
🦾
Robot Arm Kit (Acrylic / 3D Printed) The physical arm structure that holds the pen.
📟
PCA9685 Servo Driver Board Controls multiple servos easily via I²C.
🔋
5V 3A Power Supply Powers the Raspberry Pi.
6V 2A Power Supply Powers the servo motors (separate supply!).
🔌
Jumper Wires + Breadboard For connecting components.
✒️
Fine-tip Marker Pen Held by the arm to draw on paper.
📄
A4 Paper + Flat Drawing Surface Where your portrait gets drawn!
✦ ✦ ✦

⚡ Circuit Diagram

Here's how to connect all the parts together. Read carefully before wiring!

Raspberry Pi 4 GPIO 2 (SDA) GPIO 3 (SCL) 5V Power GND CSI (Camera) Pi Camera v2 Ribbon Cable PCA9685 16-Channel Servo Driver VCC (3.3V) GND SDA SCL CH0 CH1 CH2 SDA SCL Servo X MG996R — Base Rotate Servo Y MG996R — Arm Up/Down Servo Z MG996R — Pen Lift CH0 CH1 CH2 6V 2A Power Supply V+ (Servo Power) WIRE LEGEND SDA/SCL (I²C) Servo Signal Power Face Drawing Robot — Wiring Diagram
📌 COMPLETE WIRING REFERENCE PCA9685 Servo Driver ←→ Raspberry Pi 4 VCC ──────► 3.3V (Pin 1) GND ──────► GND (Pin 6) SDA ──────► GPIO 2 / Pin 3 SCL ──────► GPIO 3 / Pin 5 V+ ──────► 6V External Power Supply (+) GND (V+) ──────► 6V Power Supply (-) Servo X (Base Rotate) ──► PCA9685 Channel 0 Servo Y (Arm Up/Down) ──► PCA9685 Channel 1 Servo Z (Pen Lift) ──► PCA9685 Channel 2 Pi Camera (CSI Ribbon) ──► Raspberry Pi CSI Port Never power servo motors directly from the Raspberry Pi 5V pin. Always use a separate 6V power supply for servos — they draw too much current!
✦ ✦ ✦

🔧 Step-by-Step Build Guide

Follow these steps in order. Take your time — good robots are built carefully! 🛠️

1

🍓 Set Up Raspberry Pi OS

Flash Raspberry Pi OS (64-bit) onto a 16GB+ microSD card using the Raspberry Pi Imager tool. Boot it up, connect to Wi-Fi, and open a terminal.

TERMINAL
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install python3-pip python3-opencv -y
pip3 install adafruit-circuitpython-pca9685 adafruit-circuitpython-motor
pip3 install Pillow numpy opencv-python
2

📷 Enable Pi Camera & I²C

Enable the camera module and I²C interface so the Pi can talk to the servo driver board.

TERMINAL
sudo raspi-config

Navigate to: Interface Options → Camera → Enable
Then: Interface Options → I2C → Enable
Reboot when asked.

💡 Tip: Connect the Pi Camera ribbon cable to the CSI slot — the blue stripe faces the USB ports. Press the clip down firmly!
3

🦾 Assemble the Robot Arm

Build the 3-axis arm using your kit or 3D-printed parts. Attach servos at each joint:

  • Base joint: Servo X — rotates the whole arm left/right
  • Elbow joint: Servo Y — raises and lowers the arm
  • Pen holder: Servo Z — lifts pen up (travel) and down (draw)

Hot-glue or clip a fine-tip marker into the pen holder at the end of the arm.

4

🔌 Wire Everything Up

Follow the circuit diagram above. Key things to remember:

  • PCA9685 → Pi via I²C (SDA + SCL + 3.3V + GND)
  • Each servo's 3-pin connector → PCA9685 channel (signal/power/ground)
  • Servos powered by the separate 6V supply (V+ terminal)
⚠️ Safety First: Double-check polarity before powering on. Red = positive, Black = ground. Wrong polarity can damage your servo board!
5

📸 Python: Capture & Convert Selfie

This Python script captures a photo and converts it into a pencil-sketch style image that the robot can draw.

selfie_sketch.py
# selfie_sketch.py — Capture face & make sketch
import cv2
import numpy as np
from picamera2 import Picamera2
from PIL import Image

# ── 1. Capture selfie ──────────────────────────
picam2 = Picamera2()
picam2.start_preview()
picam2.capture_file("selfie.jpg")
picam2.stop_preview()
print("📸 Selfie captured!")

# ── 2. Convert to pencil sketch ────────────────
img   = cv2.imread("selfie.jpg")
gray  = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# Invert + blur = pencil sketch effect
inv   = cv2.bitwise_not(gray)
blur  = cv2.GaussianBlur(inv, (21, 21), 0)
sketch = cv2.divide(gray, cv2.bitwise_not(blur),
                    scale=256.0)

# Threshold to get clean lines for drawing
_, bw = cv2.threshold(sketch, 200, 255,
                       cv2.THRESH_BINARY_INV)
cv2.imwrite("sketch.png", bw)
print("✏️  Sketch image saved as sketch.png")
6

🗺️ Python: Convert Sketch to Robot Paths

This script traces the sketch image into a series of (x, y) coordinates the robot arm will follow.

image_to_paths.py
# image_to_paths.py — Find draw paths from sketch
import cv2
import numpy as np

def get_draw_paths(sketch_file):
    img = cv2.imread(sketch_file, cv2.IMREAD_GRAYSCALE)
    # Resize to match drawing area (150x150 mm robot range)
    img = cv2.resize(img, (150, 150))

    # Find contours (the lines to draw)
    contours, _ = cv2.findContours(
        img, cv2.RETR_LIST,
        cv2.CHAIN_APPROX_SIMPLE
    )

    paths = []
    for cnt in contours:
        if cv2.arcLength(cnt, False) > 10: # skip tiny dots
            path = [(pt[0][0], pt[0][1]) for pt in cnt]
            paths.append(path)

    print(f"📐 Found {len(paths)} paths to draw")
    return paths
7

Python: Control the Robot Arm

The main drawing script! It moves the servos to follow the sketch paths.

draw_face.py
# draw_face.py — Make the robot draw!
import board, busio, time
from adafruit_pca9685 import PCA9685
from adafruit_motor import servo
from image_to_paths import get_draw_paths

# ── Setup I2C and servo driver ──────────────────
i2c = busio.I2C(board.SCL, board.SDA)
pca = PCA9685(i2c)
pca.frequency = 50

# Create servo objects
servo_x = servo.Servo(pca.channels[0], min_pulse=500, max_pulse=2400)
servo_y = servo.Servo(pca.channels[1], min_pulse=500, max_pulse=2400)
servo_z = servo.Servo(pca.channels[2], min_pulse=500, max_pulse=2400)

# ── Helper functions ────────────────────────────
def pen_up():
    servo_z.angle = 90   # lift pen off paper
    time.sleep(0.3)

def pen_down():
    servo_z.angle = 50   # press pen onto paper
    time.sleep(0.3)

def move_to(x, y):
    # Map pixel coords (0-150) to servo angles (30-150°)
    angle_x = int(30 + (x / 150) * 120)
    angle_y = int(30 + (y / 150) * 120)
    servo_x.angle = angle_x
    servo_y.angle = angle_y
    time.sleep(0.05)  # small delay between moves

# ── Main drawing routine ────────────────────────
print("🎨 Starting to draw your face...")
paths = get_draw_paths("sketch.png")

pen_up()  # start with pen raised

for path in paths:
    # Travel to start of each stroke
    move_to(path[0][0], path[0][1])
    pen_down()

    # Draw the stroke
    for (x, y) in path[1:]:
        move_to(x, y)

    pen_up()  # lift between strokes

print("✅ Drawing complete! Check your paper!")
🚀 Run order: First run selfie_sketch.py, then run draw_face.py — both in the same folder!
✦ ✦ ✦

🛠️ Troubleshooting Guide

Something not working? Don't give up! Check this table first:

🔴 Problem🟡 Likely Cause✅ Fix
Camera not detected Camera not enabled or ribbon not seated Run raspi-config, enable camera, re-seat ribbon, reboot
Servos not moving PCA9685 not found on I²C bus Run i2cdetect -y 1 — should show address 0x40
Arm shaking a lot Insufficient servo power Check 6V supply amperage — needs at least 2A for 3 servos
Drawing looks distorted Servo angle mapping is off Calibrate min/max angles in move_to() function
Sketch image is too dark Threshold value too low Change threshold(sketch, 200 ...) — try 180 or 220
Pen tears paper Pen-down angle pressing too hard Change servo_z.angle = 50 to 60 or 65
✦ ✦ ✦

🚀 Make It Even Cooler!

Once your robot is drawing faces, try these awesome upgrades:

🎤
Voice Control Say "Draw me!" and the robot starts — add a USB mic and speech_recognition library.
🖥️
Live Preview Screen Add a small OLED screen to show the sketch before the robot draws it.
🎨
Multi-colour Drawing Add a pen changer — robot swaps between coloured markers automatically!
🧠
Add Face Detection Use OpenCV's face detection to auto-crop just your face before sketching.
✦ ✦ ✦

❓ Frequently Asked Questions

Do I need to know Python already?

Basic Python helps a lot! If you can understand loops and functions, you're ready. Start with free Python tutorials on YouTube if you're new.

Can I use an Arduino instead of Raspberry Pi?

Arduino alone can't run OpenCV for image processing. You can use an Arduino to control the servos and connect it to a PC or laptop that handles the image processing side.

How accurate will the drawing be?

Mechanical servo arms have some wobble. Expect a fun cartoon-style sketch, not a photorealistic portrait! That's part of the charm. 😄

How long does it take to draw one face?

A simple sketch takes about 5–15 minutes depending on how many strokes the image has. You can speed it up by simplifying the threshold in the sketch code.

Can I draw things other than faces?

Absolutely! Any photo works — pets, objects, logos. Just point the camera at anything and let the robot sketch away!

Making kids fall in love with robotics, one project at a time.

Tags: #KidsRobotics #DrawingRobot #RaspberryPi #STEMProject #FaceSketchRobot #MakeMindz

Comments

Product Cards
Buddy Bot eBook
⭐ New 2026 Release
Build Your
Own Robot!
3D design, wiring &
Arduino coding.
Young inventors love it!
🖨️
3D Print
All parts
Wire it
Circuit guide
💻
Code it
Arduino IDE
🤖
Watch it
Walk & react
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Website Offer
₹499 300
🌍 International: $5 USD
One-time · Instant digital delivery
🔒 Secured by Razorpay · Your data is safe
📄 Download Free Sample Copy
🔒 Secured by Razorpay · Your data is safe
🍓
Raspberry Pi Pico Mastery
21 Projects
⚡ Launch Price — 80% OFF
Learn Pico
Build 21 Projects!
MicroPython · Wokwi
IoT · Certificate
Perfect for beginners!
🖥️
Wokwi
No hardware
🐍
MicroPy
From zero
🔨
21 Projects
IoT + sensors
📄
Certificate
Verified cert
📋 Your Details
Enter your name
Valid 10-digit no.
Enter a valid email
Special Launch Offer
₹999 200 80% OFF
🌍 International: $5 USD
One-time · Lifetime access · No subscription
🔒 Secured by Razorpay · UPI · Cards · NetBanking
🎉

You're in!

Payment successful! Your Buddy Bot eBook is ready. Time to build!

📖 Access Your eBook Now
🎉

Enrolled!

Payment successful! Lifetime access to all 21 Pico Projects is yours!

🍓 Go to My Course