aams86
Published © GPL3+

Halloween + Micro:bit

Add some life to your Halloween decorations! Using micro:bit + LEDs, and some spooky music!

BeginnerFull instructions provided1.5 hours1,780

Things used in this project

Hardware components

BBC micro:bit board
BBC micro:bit board
×1
addressable LED strip
affiliate link
×1
3 pin led strip connector
Optional - easy alternative to soldering (affiliate link)
×1
Alligator Clips
Alligator Clips
×1
Buzzer
Buzzer
Can use any speaker
×1
5v Cell Phone Power Bank
you can use the battery case that comes with micro:bit and some AAAs, but I usually power through the usb connection using a cell phone power bank (affiliate link)
×1
Pumpkin
×1
Wax Paper
×1
Tape
×1
Paper Clips
×1

Software apps and online services

MakeCode
Microsoft MakeCode

Story

Read more

Schematics

Micro:bit wiring guide

This diagram shows how to connect the LEDs and the speaker to the micro:bit

Code

Song + Eyes + Candle

JavaScript
This is the javascript version of the makeCode blocks for this project
let g5 = 0
let b4 = 0
let ef5 = 0
let bf5 = 0
let e5 = 0
let b5 = 0
let f5 = 0
let c6 = 0
let d6 = 0
let fs5 = 0
let cs6 = 0
let candle_colors: number[] = []
let Candle_strip: neopixel.Strip = null
let eye_strip: neopixel.Strip = null
let eye_colors: number[] = []
let Full_LED_strip: neopixel.Strip = null
let Song_1: number[] = []
let candle_LED = 0
let current_candle_strip: neopixel.Strip = null
let rest_of_candle: neopixel.Strip = null
let Number_LEDs = 0
let index2 = 0
function song() {
    for (let index = 0; index <= Song_1.length; index++) {
        music.playTone(Song_1[index], music.beat(BeatFraction.Half))
        basic.pause(10)
    }
}
function eyes() {
    for (let index1 = 0; index1 <= eye_colors.length - 1; index1++) {
        for (let index22 = 0; index22 <= 255; index22++) {
            eye_strip.setBrightness(index22)
            eye_strip.showColor(eye_colors[index1])
            basic.pause(5)
        }
        for (let index23 = 0; index23 <= 255; index23++) {
            eye_strip.setBrightness(255 - index23)
            eye_strip.showColor(eye_colors[index1])
            basic.pause(5)
        }
    }
}
function candle() {
    rest_of_candle.clear()
    current_candle_strip = Candle_strip.range(0, Math.randomRange(0, candle_LED - 1 + 1) + 1)
    current_candle_strip.showColor(candle_colors[Math.randomRange(0, 1)])
    basic.pause(Math.randomRange(0, 41) + 80)
}
index2 = 0
Number_LEDs = 8
candle_LED = 4
Full_LED_strip = neopixel.create(DigitalPin.P1, Number_LEDs, NeoPixelMode.RGB)
Candle_strip = Full_LED_strip.range(0, candle_LED)
eye_strip = Full_LED_strip.range(candle_LED, Number_LEDs - candle_LED)
candle_colors = [neopixel.rgb(255, 80, 0), neopixel.rgb(255, 150, 0)]
eye_colors = [neopixel.colors(NeoPixelColors.Red), neopixel.colors(NeoPixelColors.Green), neopixel.colors(NeoPixelColors.Blue), neopixel.colors(NeoPixelColors.Purple), neopixel.colors(NeoPixelColors.Yellow)]
rest_of_candle = Candle_strip.range(1, candle_LED - 1)
music.setTempo(136)
cs6 = 1109
fs5 = 740
d6 = 1175
c6 = 1047
f5 = 698
b5 = 988
e5 = 659
bf5 = 932
ef5 = 622
b4 = 494
g5 = 784
Song_1 = [cs6, fs5, fs5, cs6, fs5, fs5, cs6, fs5, d6, fs5, cs6, fs5, fs5, cs6, fs5, fs5, cs6, fs5, d6, fs5, cs6, fs5, fs5, cs6, fs5, fs5, cs6, fs5, d6, fs5, cs6, fs5, fs5, cs6, fs5, fs5, cs6, fs5, d6, fs5, cs6, fs5, fs5, cs6, fs5, fs5, cs6, fs5, d6, fs5, cs6, fs5, fs5, cs6, fs5, fs5, cs6, fs5, d6, fs5, c6, f5, f5, c6, f5, f5, c6, f5, cs6, f5, c6, f5, f5, c6, f5, f5, c6, f5, cs6, f5, cs6, fs5, fs5, cs6, fs5, fs5, cs6, fs5, d6, fs5, cs6, fs5, fs5, cs6, fs5, fs5, cs6, fs5, d6, fs5, c6, f5, f5, c6, f5, f5, c6, f5, cs6, f5, c6, f5, f5, c6, f5, f5, c6, f5, cs6, f5, b5, e5, e5, b5, e5, e5, b5, e5, c6, e5, b5, e5, e5, b5, e5, e5, b5, e5, c6, e5, bf5, ef5, ef5, bf5, ef5, ef5, bf5, ef5, b5, ef5, bf5, ef5, ef5, bf5, ef5, ef5, bf5, ef5, b5, ef5, b5, e5, e5, b5, e5, e5, b5, e5, c6, e5, b5, e5, e5, b5, e5, e5, b5, e5, c6, e5, bf5, ef5, ef5, bf5, ef5, ef5, bf5, ef5, b5, ef5, bf5, ef5, ef5, bf5, ef5, ef5, bf5, ef5, b5, ef5, fs5, b4, b4, fs5, b4, b4, fs5, b4, g5, b4, fs5, b4, b4, fs5, b4, b4, fs5, b4, g5, b4, fs5, b4, b4, fs5, b4, b4, fs5, b4, g5, b4, fs5, b4, b4, fs5, b4, b4, fs5, b4, g5, b4, fs5, b4, b4, fs5, b4, b4, fs5, b4, g5, b4, fs5, b4, b4, fs5, b4, b4, fs5, b4, g5, b4, fs5, b4, b4, fs5, b4, b4, fs5, b4, g5, b4, fs5, b4, b4, fs5, b4, b4, fs5, b4, g5, b4, fs5, b4, b4, fs5, b4, b4, fs5, b4, g5, b4]
basic.forever(function () {
    eyes()
})
basic.forever(function () {
    song()
})
basic.forever(function () {
    candle()
})

Credits

aams86

aams86

2 projects • 9 followers

Comments