Electronic Garden with Raspberry Pi
Create a spinning electronic flower garden using Raspberry Pi, an Explorer HAT, and a geared motor.
- 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 (any model with GPIO)
- Explorer HAT Pro
- Wheel (for the motor shaft)
- Geared motor (12V 80RPM recommended)
- Jumper leads (male-to-female)
- Colored construction paper or felt
- Scissors, markers, adhesive, push pin
Install Explorer HAT software
About 5 minutes
Install the Python library for Explorer HAT.
- Power off your Raspberry Pi.
- Push the Explorer HAT onto the GPIO pins.
- Power on your Raspberry Pi.
- Open a Terminal and run the command to install the Explorer HAT library.
- Test the installation by running the Python import command.
sudo apt-get install python3-explorerhatThis installs the Explorer HAT library for Python 3.
You should see
The library installs successfully. Running 'python3 -c "import explorerhat"' produces no errors.
Connect the motor
About 10 minutes
Attach the motor and wheel to the Explorer HAT.
- Push the motor shaft halfway into the wheel.
- Attach the female ends of 2 jumper leads to the motor's prongs.
- Connect the male ends to Motor 1+ and Motor 1- on the Explorer HAT.
You should see
The motor is securely connected to the Explorer HAT terminals.
Decorate your garden
About 15 minutes
Create colorful flower decorations for the spinning wheel.
- Cut flower shapes out of construction paper or felt.
- Optionally, make origami pinwheels or draw bees and butterflies.
- Arrange your decorations on the wheel using adhesive.
- Secure everything with a push pin through the center of the wheel.
- Think about how your design will look when it spins!
You should see
Your wheel is decorated with bright, garden-themed designs.
Write the Python script
About 10 minutes
Program the motor to spin for 10 seconds.
- Open Python 3 (IDLE) from the Programming menu.
- Create a new file and save it as 'garden.py'.
- Import the Explorer HAT library and the sleep function.
- Add code to spin the motor forward at full speed for 10 seconds, then stop.
import explorerhat
from time import sleep
explorerhat.motor.one.forward(100)
sleep(10)
explorerhat.motor.one.stop()The motor speed is set to 100 (full power). You can reduce this to slow the spinning.
You should see
The script runs and the motor spins for 10 seconds, then stops.
What to do next
- Whoo-Pi CushionBuild another fun Raspberry Pi project with sound effects.
- More Raspberry Pi projectsExplore beginner Raspberry Pi builds.
Stuck? Contact Vilros Support with your board model and what you see on screen.