This project shows how to build a dancing snowman, with the Raspberry Pi and PivotPi – a servo controller built just for that!
Scratch is used to code the dancing snowman and Sonic Pi generates the Holidays music.
Step 1: What You Will Need
The snowman showcases the PivotPi so let’s start with that. You will need:
- A PivotPi
- A RaspberryPi with wifi access (either the Pi3 or another Pi with a dongle)
- 4 AA batteries
- 2 medium servos
- 1 small servo
- 6 jumper wires male to female (black,red, white, and brown,red,orange if you can choose colors)
- Raspbian for Robots SD Card
In the crafts area, you will need:
- Big tie wraps
- Strong double side tape
- Googly eyes
- Black marker
- A strong post
Step 2: Snowman Body Building
You will build the snowman out of a piece of foamboard. Use three plates of different sizes, or any round objects, that will give you a nicely proportioned snowman. Cut the pieces out and consider sanding the sides too.
Cut three Circles
Use a black marker to go around each circle, to make them stand out. And we’ve got the start of a snowman!
Step 3: Build the Snowman
Get a post of some sort that will tall enough to hold the snowman.
Attach two medium servos to the lower half of the post, eye-balling their approximate position. Servo placement determines the type of movement you will get. If you place a servo in the center of one of the circles, you’ll get a pure rotation movement. That looks good for the central part with the arms. Attach the arms to the body using tape, the arms don’t move, it’s the body that will rotate.
If you place a servo higher than the center of the body circle, you’ll get a swing effect which looks nice for the bottom part. It’s not a precise science (it could be, but it’s not necessary to be that precise for a snowman), but about 1/3 up looks nice.
The top servo – a small one – controls the head. We will use a short piece of balsa wood as a neck, the lower part of which is attached to the servo and the upper part is attached to the head. This allows the snowman to move its head side to side. The balsa wood uses double sided tape to stick to the head part. Time to decorate the snowman! Googly eyes, candy cane and all!
Middle section with arms
Bottom section with offset from center
Head and Neck
Step 4: Servo Connections
Time to connect those servos to the PivotPi board! There are three of them, but two should be a little too high. You have a couple of choices. You can put the PivotPi/RaspberryPi higher up on the supporting post by using tie-wraps or any other safe method, or you can extend the servo wires by using male to female jumper wires.
The bottom servo is connected to Port 1.
The middle servo is connected to Port 2 .
The top servo (the small one) is connected to Port 7 as my PivotPi was kept standing up and the wires could reach it (Port 8 would have been fine too).
You can change the Scratch code to match your own connections by adapting these blocks
Step 5: Speaker Connection
The speaker’s connection is easy.
- Its power cable is connected both to the speaker and to one of the Pi’s USB port
- Its audio cable goes onto the audio port on the Pi
- Its power must be turned on to the highest volume as we’ll be outside
Step 6: Scratch Code
The snowman project uses Scratch for the PivotPi. To avoid looking completely like a robot, some random generators are used. Otherwise the code is straightforward. You can learn more with our online Scratch reference page.
If you do a DI Software Update on your Raspbian for Robots card, you will be able to find the code by:
Click on File, then Open
Click on the Pi button and navigate to Dexter, PivotPi, Projects, Snowman
Step 7: Sonic Pi Code
Sonic Pi is not, by default, on Raspbian for Robots. You do not need it but it’s a fun thing to add.
To install Sonic Pi, your SD card must be at least 8 Gig with some spare room. If you have a 4 Gig one, changes are Sonic Pi won’t fit on it.
Run the following commands in a terminal window:
sudo apt-get update sudo apt-get install sonic-pi
and let it do its magic.
Raspberry Pi/ Programming / Sonic Pi
You can download Jingle Bells from Robin Newman’s collection (click on the ‘Download Zip’ button, top-right) (Huge thank yous to Robin for sharing his musical talent! )
If you need some help to transfer the file from your regular computer to your Pi, take a look at our tutorials:
Start Sonic Pi by clicking on the Pi’s little red raspberry menu, then Programming, then Sonic Pi.
Load the Sonic Pi file by clicking on the Load button, and finding the place where you saved it on the Pi.
Once your speaker is plugged into the Pi and switched on, you can click on the Run button and listen to your Pi create music!
Step 8: How to Get the Code for This Project
The easiest way to get the code is to update your Dexter Industries software through the “DI Software Update”. When you do this, all of the code files for new projects like this will show up!
When you run the DI Software Update, this project can be found in this location:
If you are not using the Dexter Industries custom software, Raspbian for Robots, and you still want to download this file, you can download it here.
Step 9: Need Help?
Have a question or a problem? Post it on the forums and we’ll help you out.
Participated in the
Soft Toys Challenge