Do You Want to Build a Snowman?

Do You Want to Build a Snowman?

Do You Want to Build a Snowman?

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.

What You Will Need

The snowman showcases the PivotPi so let’s start with that. You will need:

  1. A PivotPi
  2. A RaspberryPi with wifi access (either the Pi3 or another Pi with a dongle)
  3. 4 AA batteries
  4. 2 medium servos
  5. 1 small servo
  6. 6 jumper wires male to female (black,red, white, and brown,red,orange if you can choose colors)
  7. Speaker
  8. Raspbian for Robots SD Card

In the crafts area, you will need:

  1. foamboard
  2. big tie wraps
  3. strong double side tape
  4. googly eyes
  5. black marker
  6. a strong post

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.

Use a black marker to go around each circle, to make them stand out. And we’ve got the start of a snowman!

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!

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

Snowman Port Connections

 

Speaker Connection

 

The speaker’s connection is easy.

  1. Its power cable is connected both to the speaker and to one of the Pi’s USB port
  2. its audio cable goes onto the audio port on the Pi
  3. its power must be turned on to the highest volume as we’ll be outside

 

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

snowman

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

Find snowman code

Find the Snowman Code

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.

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:

Transfer Files from a Mac

Transfer Files from a PC

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!

 

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!

File Path

When you run the DI Software Update, this project can be found in this location:
/home/pi/Dexter/PivotPi/Projects/Snowman

Downloadable File:

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.

Need help?

Have a question or a problem?  Post it on the forums and we’ll help you out.

Need help?

pivotpi-header