Third party cookies may be stored when visiting this site. Please see the cookie information.

PenguinTutor YouTube Channel

Talking Reindeer - Raspberry Pi electronics programming project

When looking in Hobbycraft for Christmas craft ideas we came across their Decopatch Reindeer head. If you've not heard of Decopatch before, it's basically like papermache, but you start with a pre-made shape (in this case a reindeer head) and cover it with little bits of patterned paper to make a decorative feature. See: Hobbycraft Decopatch ideas. We knew instantly that we wanted to decorate one, but my daughter and I also looked at it as something we could improve with the help of a Raspberry Pi.

Version 0.0.2 - added support alternate PIR sensor

I have updated the code to support two different PIR sensors. The original one is the Zilog PIR sensor which uses serial communication and is run using the command The new one PIR sensor is easier to include in a program as it uses a simple on/off signal to indicate if the PIR sensor has been triggered. This is the same as the sensor used in the Raspberry Pi Parent Detector.

Talking Reindeer - Raspberry Pi powered interactive Christmas decoration

The Reindeer uses a PIR sensor to detect someone approaching it and in response plays an audio file (pre-recorded talking) and flashes LEDs on it's antlers.

This is a project that the whole family can get involved in. There is a little soldering required, but most of this is done using a breadboard and screw terminals.

Video introduction to the Talking Reindeer

See the following video for a short introduction to the talking reindeer

Shopping list

Below are the things you need to build the talking reindeer.

  • Cardboard reindeer head (or similar)
  • Decopatch paper and glossy glue
  • Red tissue paper (for nose)
  • Raspberry Pi (model A or B)
  • SD card with NOOBS installed (you can download and install to any SD card)
  • Micro USB power supply (with long lead / USB extension lead)
  • Mini Wifi USB dongle
  • PIR sensor (Zilog or standard)
  • 1 x 100K resistor (only if using zilog pir sensor)
  • 6 x LEDs
  • 6 x 100R resistors
  • 2 x light pipes (optional)
  • 7406 - Hex inverting buffer with open collector outputs
  • Thin wire
  • Heatshrink sleeving (for LED wire joint and for light pipes
  • Solderless breadboard (or two mini breadboards)
  • Terminal connectors
  • Assorted leads for breadboard and Raspberry Pi (including male to female jumper leads)
  • Speaker (with audio extension lead if required)
  • Tinsel (optional to hide power and audio leads)
  • Clear tape (eg. Sellotape)

You will also need soldering equipment (soldering iron / solder), knife (preferably DIY knife) and a thick child's paintbrush.

The craft items were bought from a local Hobbycraft store, the Zilog PIR sensor and the light pipes from SK Pang, the 7406 IC and the White LEDs are available from CPC Farnell, and the rest are available from various suppliers (eg. Farnell, Maplin, ModMyPi).


The first task was to decorate the reindeer head. We used three different patterns of Decopatch (it's not clear from the photo, but the reindeer's ears have a different pattern) and red tissue paper for the nose. Glue is applied with a paintbrush and then torn up bits of paper stuck on top. The ink from the tissue paper comes out into the glue so care should be taken to avoid getting red over the rest of the reindeer. The antlers should not be attached to the reindeer head at this stage.

A hole needs to be cut into the back of the head to allow the electronics to be inserted inside. I recommend a strong DIY knife (such as a Stanley Knife) rather than a craft knife as I broke a craft knife when first tried.

Care should be taking when using a knife. It is recommended this is done by an adult or under close adult supervision.

Raspberry Pi Setup

The Raspberry Pi is configured with a Wifi USB dongle to connect to the home wireless network. It has the standard NOOBs Raspbian image with a web server (so that I can be controlled remotely). There is a speaker connected to the 3.5mm audio socket. In my case I have mounted the speaker externally and connected it to it's own USB power supply, or if you have a small speaker and a Model B Raspberry Pi then you could use the second USB port for powering a speaker.

See the following guides for details of how to configure the Raspberry Pi:

I set my IP address to (25 makes it easier to remember based on a certain date in December). Depending upon your router configuration you may need to choose a different address. For the webserver setup you can skip the networking section as that is already taken care of with the wireless network setup and there is no need to install Mysql. PHP is required.

PIR Sensor

I have already posted details of how to Use the Zilog PIR sensor with the Raspberry Pi. The alternative PIR sensor is easier to program by just checking the appropriate GPIO port as an input.

To avoid having to solder on to the sensor or Raspberry Pi, I used male-to-female jumper leads to a small breadboard (which also had the resistor) and then male-to-female jumper leads to the Sensor. The sensor is mounted at the bottom of the reindeer head and held in place behind the reindeer using tape.

Soldering the LEDs

I have kept the soldering to a minimum, but long leads are needed between the LEDs and the breadboard. I did want my children to be involved in making the circuit. In an earlier family Raspberry Pi project I encouraged my children (age 5 and 8) to do some soldering, but I literally held my childrens hands whilst they soldered. This time I let them control the soldering iron on their own. I mounted the LED and wire into a "helping hand" and let my children put the soldering iron onto the join whilst I added the solder. It worked quite well and I think was better than when I held their hand to control the soldering iron. Obviously I gave them a talk about how hot the soldering iron was, warned them that it could burn them and the safe way to hold the soldering iron. They were closely supervised during this.

An LED has to be connected the right way around and I was using just one colour of wire (white) so I marked the distant end of the wire with a red for the anode (positive end) and black for the cathode (negative end) to make it easier when connecting it up later. On an LED the anode is denoted by a longer lead and the cathode by a shorter lead and a flat spot on the side of the LED.

Talking Reindeer - Raspberry Pi powered interactive Christmas decoration - electronics project

The leads of the LEDs were then covered in a transparent heat shrink sleeving (white would have worked as well, but I had transparent available), and for two of the LEDs I connected them to light pipes using heat shrink sleeving. My children held the heat gun for the heat shrink sleeving, after the usual safety explanation and under supervision.

I used terminal blocks to connect the wires to the breadboard so that it only needed to be soldered at one end. The LEDs are fixed to the antlers using clear tape. Once the LEDs are in place then the antlers can be pushed into their mounting holes on the reindeer head and if neccessary a small amount of clear tape used to secure the antlers in position.

Buffering the GPIO for the LEDs

The GPIO ports on the Raspberry Pi can only handle a maximum of 16mA, but the LEDs that I chose were able to use 30mA to achieve full brightness. Rather than risk damaging the Raspberry Pi I decided to put an additional buffer stage. I happened to have a 7406 Hex inverting buffer IC, which has open collector outputs. The open collector means that when it has a low output it can be used to drive the LEDs which are then connected to the 5v supply using a 100 ohm resistor. The 7406 happens to support 6 outputs each at 30mA which is exactly what I needed.

The 7406 is an old IC and is not as widely available as some other ICs. If you would like an alternative or to run more LEDs from the same signal then you could use a darlington driver IC or individual transistor switch circuits instead.

Raspberry Pi Reindeer project breadboard with electronic circuit

The 7406 was mounted on a small breadboard and wired up as below.

7406             RPi 

---------        ---

pin 1  (1A)   to  pin 16 (GPIO23)

pin 2  (1Y)   to  LED cathode

pin 3  (2A)   to  pin 18 (GPIO24)

pin 4  (2Y)   to  LED cathode

pin 5  (3A)   to  pin 22 (GPIO25)

pin 6  (3Y)   to  LED cathode

pin 7  (GND)  to  pin 14 (GND)

pin 8  (4Y)   to  LED cathode

pin 9  (4A)   to  pin 7  (GPIO4)

pin 10 (5Y)   to  LED cathode

pin 11 (5A)   to  pin 11 (GPIO17)

pin 12 (6Y)   to  LED cathode

pin 13 (6A)   to  pin 15 (GPIO22)

pin 14 (VDD)  to  pin 2  (5V0) 

I have used different ports for the PIR sensor. See the file for more details.

In the actual breadboard layout the resistor is located between the LED cathode and the output pin of the 7606.

Audio files

For the example video I have used some voice files created using Audacity on a Linux laptop. In actual use we will also be adding short music clips, which have not been included in the video for copyright reasons (although as I understand short clips are now permitted under UK copyright law).

The video files should be saved in the same folder as the rest of the code (below), or the code can be updated with the full path of the files.

Source code

The software can be downloaded from:

or by issuing:

Unzip the files into the pi home directory using:
tar -xvzf reindeer-0.0.2.tgz

The directory needs to be renamed to just reindeer instead of reindeer-0.0.2. This can be achieved using:
mv reindeer-0.0.2 reindeer

Move the following files to the web server home directory (/var/www/):

  • index.php
  • reindeer.css
  • reindeer.js
  • reindeer.jpg
  • jquery-2.0.3.min.js

This can be done using:

cd reindeer

mv *.php *.css *.js *.jpg /var/www/

The python script can be run from the command line to test it is working using one of the following (z for zilog, p for other PIR sensor):
sudo ./
sudo ./

To make it run automatically add the following entry into /etc/rc.local:
cd /home/pi/reindeer && /usr/bin/python &
change to if required.

How the software works

The software has a single configuration file. This file is updated through the web application, but is then used by the python code to determine what mode it should work in (pir / always on / always off) and whether audio is on or off. The python script checks the last modification time (mtime) of the file during each loop to see if it's been updated and needs to be reloaded.

During the loop as appropriate the python code will check the PIR sensor and then trigger playing a random audio file (if enabled) and flash the lights in the sequence in the code.

The one modification that is needed to the code is to update the audiofiles array with the filenames of the audio files (which should be stored in /home/pi/reindeer.

audiofiles = ['happychristmas.wav','happynewyear.wav','hohoho.wav','jinglebells1.wav','rudolph1.wav','wishyoumerrychristmas.wav']

You can add as many different files as you like and one will be selected at random for each time the sequence is triggered.

Python programming for a child

My daughter has been learning Scratch through a Code Club that I've been running at her school. This is however the first time she's done any Python programming. Clearly it would be too complicated to expect her to start writing the serial communications with the PIR sensor at this stage so I had her create the code to flash the LEDs.

I started by adding the comments "### Flash lights" which told my daughter where she should enter her code.

First we started using the GPIO.output command directly. Which was simple enough, but she quickly realised that it would involve a lot of programming as it needed a line of code for every LED that changed status.

I then explained about functions and had my daughter write the set_leds(...) function. It takes 6 inputs to the function which are used directly in the GPIO.output commands. It would have been possible to pass the values as a single array or a single Hex code rather than use 6 variables (which would have made it easier to create different light sequences), but at this stage I wanted to keep it simple and easy for her to visualize as the combination of 1's and 0's in the code looks the same as the LEDs.

At first we put a few individual lines in the program with different LED sequences. Again it was evident that this was going to need a lot of lines of code to work so I explained the for loop - which was similar to the loops she had been doing in her Scratch programming.

I think this provided a good bit of coding for a child that is only eight years old. She's more able to program in Scratch, but it's given her a taste of what Python programming is about.

PHP program and how web page interacts with the Python script

The web interface is provided through a PHP script with a little Javascript. It's designed with for a small screen such as a web browser on a mobile phone, but will work on any browser that supports Javascript.

I needed a way for the PHP script in the browser to communicate with the python script. There are several ways this could be achieved, but I thought the easiest would be to use a file that is updated by the PHP script and then read by the Python script. As there is only a single message that needs to be passed through "play now" then this can be done by updating the last modified time by using touch in php and then reading the mtime in python to see if it's been updated.


At the end of this we have a unique Christmas decoration that looks good. In the process had fun with my children and taught my daughter a bit of python programming.

Also see Updated Christmas Reindeer project with Google AIY

More information about the Raspberry Pi

See the guides and blog posts relating to the Raspberry Pi.

Previous Halloween 2
Halloween 2
Next AIY Christmas Reindeer
AIY Christmas Reindeer