Skip to content

Build Your Own Robot with Raspberry Pi

Create a cardboard robot with LED antenna and sound effects using Raspberry Pi, perfect for kids and beginners.

  • Raspberry Pi
  • Beginner
  • 45–60 minutes
  • 5 steps

Shop this project

Cart

You'll need

Prices from vilros.com. Tax and shipping at checkout.

Before you start, you'll need

  • Raspberry Pi 2 or 3
  • Resistor (100Ω or higher)
  • LED
  • 3 female-to-female jumper leads
  • Headphones or small speaker
  • Construction paper (8.5×11)
  • Toilet paper roll (cardboard)
  • Pens, crayons, markers
  • Scissors
  • Tape or glue
  • Modeling clay (small piece)

Build the LED antenna

About 10 minutes

Create an LED circuit with resistor.

  1. Connect one jumper wire to the long leg of the LED (positive/anode).
  2. Connect the resistor to the other end of that wire.
  3. Connect another jumper wire to the free end of the resistor.
  4. Connect a third jumper wire to the short leg of the LED (negative/cathode).

You should see

The LED has two wire connections: one through a resistor to the positive side, one direct to the negative side.

Connect antenna to Raspberry Pi

About 5 minutes

Wire the LED circuit to GPIO pins.

  1. Turn off your Raspberry Pi before connecting.
  2. Connect the wire from the resistor to a 3V3 pin on the Pi.
  3. Connect the wire from the short LED leg to a GND pin.
  4. Power on your Raspberry Pi.
  5. The LED should light up, confirming a complete circuit.

You should see

The LED lights up when the Pi is powered on.

Program the LED to flash

About 15 minutes

Write Python code to make the LED blink and beep.

  1. Disconnect the LED from 3V3.
  2. Connect that wire to GPIO pin 17 instead.
  3. Open Python 3 on your Raspberry Pi.
  4. Copy and run the code below to make the LED flash.
  5. Add sound effects by importing pygame and playing .wav files.
python
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

led_pin = 17
GPIO.setup(led_pin, GPIO.OUT)

print("Robot antenna starting!")

for i in range(10):
    GPIO.output(led_pin, GPIO.HIGH)
    print("Beep!")
    time.sleep(0.5)
    GPIO.output(led_pin, GPIO.LOW)
    time.sleep(0.5)

GPIO.cleanup()
print("Robot antenna done.")

For sound, add pygame.mixer.Sound('beep.wav').play() in the loop.

You should see

The LED flashes on and off 10 times.

Construct the cardboard robot

About 15 minutes

Create and decorate the robot body.

  1. Draw a robot design on construction paper (human-like, monster, animal, or your own creation).
  2. Make sure to draw an antenna at the top.
  3. Decorate with colors, stickers, or other craft supplies.
  4. Tape or glue the paper around the toilet paper roll.
  5. Put the LED circuit and wires inside the tube.
  6. Place a small piece of modeling clay inside the roll behind where the antenna should be.
  7. Use a pen to puncture a hole through the antenna spot.
  8. Remove the clay and push the LED through the hole so it sticks out as the antenna.

You should see

The robot is assembled with the LED antenna poking through the top.

Activate your robot

About 5 minutes

Run the Python script and watch your robot come to life.

  1. Connect headphones or a speaker to your Raspberry Pi.
  2. Run the Python script again.
  3. Watch the LED antenna flash and listen to the sound effects.
  4. Modify the code to change flash patterns or add more sounds.

You should see

Your robot's antenna flashes and makes sounds.

It didn't work
  • LED doesn't flash.

    Check that the LED is connected to GPIO 17 (not 3V3). Verify the resistor and wiring. Run the script from the terminal to see error messages.

What to do next

Stuck? Contact Vilros Support with your board model and what you see on screen.