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:
- Rollo145's Door Creaking.
- Hilton Productions' Scary Laugh.
Supplies
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:
- Download the files from GitHub:
- Click on Raw button on edubit-halloween.py and use Save as in browser to download the file.
- Click on doorcreak4.raw, laugh1a.raw and laugh1b.raw in audio directory, click on Raw on each to download the file.
- Connect the micro:bit to the computer using a USB cable (not a charge-only one!).
- Go to the micro:bit online editor in a browser: https://python.microbit.org/
- Click on Connect, the micro:bit should appear as an entry called BBC micro:bit CMSIS-DAP - select that and click on connect.
- Click on Load/Save and then load the edubit-halloween.py file in the top section of the pop-up.
- 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.
- Click on the cross at the top right of the pop-up to close it.
- 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:
- external speakers connected to the 3.5mm output with the Music Bit switch set to EXT;
- external speakers again but this time a Korg NTS-1 is processing the audio with a submarine reverb;
- 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:
- Customise the sounds. Making your own raw audio files for the micro:bit is described in Instructables: PIR Movement Alarm With BBC Micro:bit and External Speaker.
- Add more servos for more animation of the scene. The EDU:BIT has connections for three servos. The Kitronik Linear Actuator is an interesting addition for movement in a straight line.
- Use the Potentio Bit to manually control the door.
- Use the Sound Bit to
- trigger the scene or
- make a lip-sync'ed skull.
If you're quick you can enter one of the 2021 Halloween competitions:
Related projects:
- micro:bit halloween house - six simple projects with the micro:bit.
- Martine Segers: Projecting a microbit face on a ghost - again with a little Lego magnifying glass (Twitter) - interesting technique, may only be useful in darkened room.
- KidsCodeJeunesse: Getting musical and spooky with micro:bit (YouTube) - musical coffin made with two micro:bits.
- Stu Lowe: Halloween neopixel jack-o-lanterns - Coding with micro:bit - Part 10 (YouTube) - laser-cut wooden pumpkins, NeoPixels and MakeCode.
- Instructables: Using the Cytron Edu:bit With the Adafruit CLUE - the micro:bit V1 and V2 are both good choices for the EDU:BIT, the CLUE offers a 240x240 colour display and CircuitPython.
- Adafruit Forums: Halloween candle for Circuit Playground Express - make a simple flickering candle with a different board, the Adafruit Circuit Playground Express.
- Adafruit Learn: Jack-o-Theremin - another Circuit Playground Express project using an ultrasound sensor.
- Instructables: Kitronik: BBC Micro:bit Powered Halloween Fancy Dress
- Instructables: CeciliaHillway: Simple Animatronic With Micro:bit - shows what can be done with three servos and a micro:bit.
Further reading:
- Cytron Technologies: How RC servos work?
- Future Learn: What is physical computing? - free courses on physical computing.