The Wicked Witch

It’s Halloween today, so it’s time for a new project.

Some time ago, my son very casually said: “Hey dad, I would like a talking witch for Halloween”.

Challenge accepted!


I ordered the necessary components:

  • A Raspberry Pi Zero WH (bottom right) for the programming
  • A HiFiBerry MiniAMP (bottom middle) to play sound
  • A PIR sensor for the motion detection part
  • A speaker


It’s very easy to connect the Pi Zero and the MiniAMP. The MiniAMP is a HAT (Hardware Attached on Top), so you can just slide it on the GPIO pins of the Pi Zero.

But the PIR sensor poses a problem then. All the GPIO pins are used by the HAT, and there are no free pins anymore for the PIR sensor.

The MiniAMP actually only uses a couple of pins (as described in their support pages). It is possible to solder the PIR sensor to the unused pins of the MiniAMP board, but that’s a rather permanent solution.

Instead, I reused a small GPIO pin reference board. I soldered the PIR sensor to that board, and added the board between the Pi Zero and the HAT.

After that, I built a Lego case to hold all the electronics, and to protect it in case of rain. This case can also be attached to the witch itself.


The program plays a random sound whenever motion is detected.

import RPi.GPIO as GPIO
import time
import pygame
import random

#initialize motion sensor
PIN = 12

#initialize sound
pygame.mixer.pre_init(frequency=44100, size=-16, channels=2, buffer=4096)

#sound list
_sounds = ['Witch01.mp3','Witch02.mp3','Witch03.mp3','Witch04.mp3','Witch05.mp3','Witch06.mp3']

#wait till sensor is activated
print ("Start sensor...")
print ("Sensor activated...")

while True:
   if GPIO.input(PIN):
        print ("Movement detected! " + (time.strftime("%H:%M:%S")))
        next_sound = random.choice(_sounds)"/home/pi/Documents/Programs/WickedWitch/Sounds/"+next_sound)
        while == True:

The Wicked Witch

And here she is…

Wicked Witch

Related posts

If you’re looking for more Halloween-related posts, then you check the pumpkins of last year and the year before. Or you can check my scary cupcakes.

And for more Raspberry Pi fun, you can check for example the timer button, the hedgehog photo booth or the automatic roller shutter.

6 thoughts on “The Wicked Witch

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s