Domino building robot using Raspberry pi

Domino Building Robot with Raspberry Pi | Fun Robotics Project for Kids
Kid-Friendly Robotics Project

🁢 Build a Domino-Placing Robot with Raspberry Pi!

Meet your new robot helper that can see a line of dominoes with its camera "eye" and place new ones perfectly — powered by a Raspberry Pi, a servo motor, and the Pi Camera Module.

What You'll Build

This robot uses a Pi Camera as its "eye" to look at a row of dominoes already on the table, a Raspberry Pi as its "brain" to figure out where the next domino should go, and a servo motor as its "arm" to gently tip a new domino into place — one at a time, building a long domino chain all by itself!

🎯 Why Kids Love This Robotics Project

This is a brilliant Raspberry Pi robotics project for kids because it combines three exciting ideas in one build: a camera that "sees", a servo motor that moves, and a tiny computer that makes decisions in between. It's a gentle, hands-on introduction to computer vision and robotics — way more fun than a worksheet!

Fun Fact: The world record for the most dominoes toppled in a chain reaction is over 4.8 million! Robots like factory arms are sometimes used to help set up these giant domino art installations.

🧰 Materials You Need

🖥️Raspberry Pi (3B+/4/5)
📷Pi Camera Module
⚙️1x Micro servo (SG90)
🧱Small wooden/plastic dominoes
🔋5V power supply for Pi
🔗Jumper wires
📏Cardboard or 3D-printed arm
🧵Hot glue / small screws

🛠️ Step-by-Step Building Instructions

1

Build the Robot Frame

Cut a sturdy base from cardboard or a wooden board. This base will hold the Raspberry Pi, the servo arm, and the camera mount steady while the robot works.

2

Mount the Pi Camera

Fix the Pi Camera Module on a small stand so it points down and forward at the table where the dominoes will be placed — like a bird's-eye view of the construction zone.

3

Build the Servo "Arm"

Attach a flat lever (a craft stick or 3D-printed paddle) to the servo's rotating arm. This paddle will gently push each new domino upright into its spot.

4

Set Up the Domino Feeder

Create a simple ramp or slot (a folded piece of cardboard works!) that holds a stack of dominoes and drops one at a time into position in front of the servo arm.

5

Connect the Servo to the Pi

Wire the servo's signal, power, and ground wires to the Raspberry Pi's GPIO pins, following the circuit diagram below.

6

Connect the Pi Camera

Carefully slide the camera ribbon cable into the Pi's CSI camera port (the blue side faces the USB ports) and lock the clip gently.

7

Install Software

On the Raspberry Pi, enable the camera in raspi-config and install the picamera2, opencv-python, and gpiozero libraries.

8

Upload the Code & Test

Run the Python program below. It checks the camera image for the last domino's position, then tells the servo arm to place the next one at the right spot and angle!

🔌 Circuit Diagram

Layout:

        RASPBERRY PI (GPIO header)
        ┌────────────────────┐
        │  5V  ●──────┬──────┼── Servo Power (red)
        │  GND ●──┬───┼──────┼── Servo Ground (brown)
        │ GPIO17●─┼───┼──────┼── Servo Signal (orange)
        └────────────────────┘
                  │   │
              CSI Camera Port
              (Pi Camera ribbon cable)
      
ComponentWireRaspberry Pi Connection
Servo MotorSignal (orange/yellow)GPIO 17
Servo MotorPower (red)5V pin
Servo MotorGround (brown/black)GND pin
Pi Camera ModuleRibbon cableCSI Camera Port

Tip: If your servo shakes the Raspberry Pi's power, use a separate 5V/2A power source for the servo and connect its ground to the Pi's ground.

💻 Python Code

domino_robot.py
from gpiozero import Servo
from picamera2 import Picamera2
import cv2
import time

# ---- Setup the servo "arm" ----
arm = Servo(17)  # GPIO 17

# ---- Setup the Pi Camera ----
camera = Picamera2()
camera.configure(camera.create_preview_configuration())
camera.start()
time.sleep(2)  # let the camera warm up

def find_last_domino_position(frame):
    """
    Looks at the camera image and finds the rightmost
    dark rectangle (the last placed domino).
    Returns the x-position (in pixels) of that domino.
    """
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    _, thresh = cv2.threshold(gray, 80, 255, cv2.THRESH_BINARY_INV)
    contours, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

    last_x = 0
    for c in contours:
        x, y, w, h = cv2.boundingRect(c)
        if w * h > 200:  # ignore tiny noise
            last_x = max(last_x, x + w)
    return last_x

def place_domino():
    """Swing the servo arm forward to push a new domino upright."""
    arm.value = -1     # pull back to "ready" position
    time.sleep(0.4)
    arm.value = 1       # push forward to stand the domino up
    time.sleep(0.4)
    arm.value = 0        # return to neutral
    time.sleep(0.4)

print("Domino robot starting... press CTRL+C to stop.")

try:
    while True:
        frame = camera.capture_array()
        last_x = find_last_domino_position(frame)

        # If there is room on the table, place the next domino
        if last_x < frame.shape[1] - 50:
            place_domino()
            print("Placed a new domino! Last position:", last_x)
            time.sleep(1)  # give it time to settle
        else:
            print("Reached the end of the table. Chain complete!")
            break

except KeyboardInterrupt:
    print("Stopping robot.")

finally:
    camera.stop()
How it works: The Pi Camera takes a picture, and a bit of computer vision (using OpenCV) looks for the last domino in the row. The Raspberry Pi then tells the servo arm to swing forward and tip a new domino into place — just a little further along the line!

🌟 Tips for a Better Domino Robot

  • Use good, even lighting so the camera can clearly see the dark dominoes against a light table.
  • Start with bigger, chunkier dominoes — they're easier for the servo arm to handle precisely.
  • Keep the camera mount very still; even small wobbles can confuse the position detection.
  • Test the servo arm's push motion on its own first, before adding the camera logic.
  • Place a contrasting mat (e.g., white table, dark dominoes) for the easiest computer vision results.

❓ Frequently Asked Questions

Do I need to know Python to build this?

A little helps, but the code above is ready to copy and run. Beginners can install the libraries, upload the code, and start experimenting from there.

Which Raspberry Pi model works best?

Raspberry Pi 4 or 5 are great for smooth camera processing, but a Pi 3B+ will also work for this beginner-level project.

Can I use a webcam instead of the Pi Camera?

Yes! You can swap picamera2 for OpenCV's cv2.VideoCapture(0) if you're using a USB webcam instead.

What age group is this project good for?

With an adult's help for wiring and software setup, kids aged 10 and up can enjoy building and coding this project.

🏆 You Did It!

You just built a robot that can see, think, and build with dominoes — all on its own! Try changing the domino spacing, adding curves to the chain, or even teaching it to place dominoes in a spiral pattern.

Made with 🁢 dominoes, code, and curiosity — Happy Building!

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