Introduction: Halloween Spooky Ghost With BBC Micro:bit on Cytron EDU:BIT

This article shows how to use the Cytron EDU:BIT and its BBC micro:bit to make a fun Hallowe'en scene. A MicroPython program

  • controls the servo to animate the scene,
  • illuminates it with the RGB Bit (an array of four RGB pixels),
  • makes the eyes glow using two of the micro:bit's LEDs,
  • all while playing sound samples on the micro:bit using the Music Bit for output.

The IR bit, a proximity sensor, is used to start the animation sequence. The Music Bit has a small 7.5mm speaker but it also has a 3.5mm socket for audio output which routes the micro:bit P0 pad to both the left and right channels. This is useful to plug into amplified speakers.

The micro:bit V1 is used here but the V2 also works very well with the EDU:BIT.

The EDU:BIT is an excellent kit designed for young children to introduce them to block-based MakeCode programming and physical computing. If you don't have an EDU:BIT the Halloween scene could also be made with a micro:bit V2, an RGB pixel stick and a 3.3V compatible micro-servo and a distance sensor. The power limit of the micro:bit V1's 3.3V output means it's not suitable for directly powering four RGB pixels and a servo together.

I backed the original Kickstarter campaign for five EDU:BITs as they made great Christmas gifts. The board in this article is a sample Cytron kindly sent to me to let me test compatibility and usability with the Adafruit CLUE - it's identical to the current production version.

The audio samples are excerpts from two clips on freesound.org:

Supplies

  • Cytron EDU:BIT - PiHut | Digi-Key - there are two versions of the kit, one with and one without micro:bit.
  • BBC micro:bit - PiHut | Adafruit
  • Art and craft material for building your Halloween scene.

Step 1: Detaching the Bits From the EDU:BIT

The video above shows how to snap off the bits from a new EDU:BIT.

After removing the bits take three grove cables and attach the Music Bit, IR Bit and RGB Bit to the board in their original positions. The servo connects on the top right block of pins at position 1 with

  • yellow to S,
  • orange to +,
  • brown to -.

The EDU:BIT has a dedicated controller for up to three servos using 5V power. This avoids the need to find servos that are compatible with 3.3V control signal and power.

Step 2: Install Code and Audio Files Onto the Micro:bit

For a browser with WebUSB support like Google Chrome or Microsoft Edge:

  1. Download the files from GitHub:
    1. Click on Raw button on edubit-halloween.py and use Save as in browser to download the file.
    2. Click on doorcreak4.raw, laugh1a.raw and laugh1b.raw in audio directory, click on Raw on each to download the file.
  2. Connect the micro:bit to the computer using a USB cable (not a charge-only one!).
  3. Go to the micro:bit online editor in a browser: https://python.microbit.org/
  4. Click on Connect, the micro:bit should appear as an entry called BBC micro:bit CMSIS-DAP - select that and click on connect.
  5. Click on Load/Save and then load the edubit-halloween.py file in the top section of the pop-up.
  6. Under Project Files at the bottom of the pop-up, click on Show Files (1) to expand the list. Click on Add file at the bottom to add each of the three raw audio files.
  7. Click on the cross at the top right of the pop-up to close it.
  8. Click on Flash - this will download all four files to the (connected) micro:bit and start the program.

The useful connection functionality in the online editor depends on WebUSB and having recent firmware on the micro:bit. If you are using a different browser or this does not work then you can use the online editor's save function to save a hex file onto the MICROBIT drive.

This is worth testing before you assemble the scene to ensure everything works properly and to set provisional values for the angles for door open and door closed. There are two variables near the top of the code in the edubit-halloween.py file for these:

### Angles for door open/closed - these are likely to need tuning
DOOR_CLOSED = 35
DOOR_OPEN = 140

Step 3: Build the Scene

This scene was built with

  • a glow in the dark skeleton (from Sainsbury's),
  • a piece of thin cardboard for the wall (from a cereal packet),
  • felt-tip pens to colour the wall,
  • brown acrylic paint for the front and back of the door,
  • two LED tea lights from a pound shop,
  • a small metal U shape made from a rectifier diode lead and
  • Blu Tack (reusable putty) for temporary assembly including attaching the servo upside-down as a door opener.

The pitch (spacing) between LEDs on a micro:bit is 4mm (5/32 inch). The program currently illuminates two of the micro:bit LEDs which are 8mm apart but this could be adjusted for your ghost, ghoul, skull or skeleton.

The angles for the door being open and closed are set in the program. These are going to need tweaking for your scene depending on the servo's position, the arm position on the servo and how you connect the arm to the door.

Step 4: Test and Enjoy

The video above shows the scene being triggered repeatedly by waving a hand in front of the IR bit out-of-shot. The video features three different sound outputs:

  1. external speakers connected to the 3.5mm output with the Music Bit switch set to EXT;
  2. external speakers again but this time a Korg NTS-1 is processing the audio with a submarine reverb;
  3. the small 7.5mm speaker on the Music Bit (INT).

Step 5: Going Further

Once you've made your Halloween scene, here's some ideas for enhancements:

If you're quick you can enter one of the 2021 Halloween competitions:

Related projects:

Further reading:

Halloween Contest

Participated in the
Halloween Contest