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
CartYou'll need
Raspberry Pi 54GB / Vilros Essentials Kit$149.99
Male-Male Jumper Wires (Set of 65-assorted sized and colors)$6.99
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.
- Connect one jumper wire to the long leg of the LED (positive/anode).
- Connect the resistor to the other end of that wire.
- Connect another jumper wire to the free end of the resistor.
- 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.
- Turn off your Raspberry Pi before connecting.
- Connect the wire from the resistor to a 3V3 pin on the Pi.
- Connect the wire from the short LED leg to a GND pin.
- Power on your Raspberry Pi.
- 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.
- Disconnect the LED from 3V3.
- Connect that wire to GPIO pin 17 instead.
- Open Python 3 on your Raspberry Pi.
- Copy and run the code below to make the LED flash.
- Add sound effects by importing pygame and playing .wav files.
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.
- Draw a robot design on construction paper (human-like, monster, animal, or your own creation).
- Make sure to draw an antenna at the top.
- Decorate with colors, stickers, or other craft supplies.
- Tape or glue the paper around the toilet paper roll.
- Put the LED circuit and wires inside the tube.
- Place a small piece of modeling clay inside the roll behind where the antenna should be.
- Use a pen to puncture a hole through the antenna spot.
- 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.
- Connect headphones or a speaker to your Raspberry Pi.
- Run the Python script again.
- Watch the LED antenna flash and listen to the sound effects.
- 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
- Electronic GardenBuild another fun Raspberry Pi project with lights.
- More Raspberry Pi projectsExplore beginner Raspberry Pi builds.
Stuck? Contact Vilros Support with your board model and what you see on screen.