For World Book Day my son dressed up as the BFG. So, of course, I had to make him a micro:bit dream jar!
For world book day my son is going as the #BFG complete with a #microbit glowing dream jar @microbit_edu #WBD2017 pic.twitter.com/uVxqcOJA0I
— Lorraine Underwood (@LMcUnderwood) February 28, 2017
BUILD
I used the following equipment
- 1 x pink jar bought from St John’s Hospice charity shop
- Some bubble wrap
- 1 x micro:bit
- 1 x CodeBug GlowBug neopixel http://www.codebug.org.uk/shop/
- 3 x white crocodile clips
I connected the glowbug to the micro:bit using the crocodile clips.
micro:bit | GlowBug |
---|---|
0 | Data In |
GND | GND |
3V | 5V |
I used white crocodile clips so they would be camaflouged in the bubble wrap.
CODE
- Create a new variable and call it myLights (Variables > Make a Variable)
- Set myLights to RGB Neopixels at P0 using the block below:
To save battery, the lights only come on when the micro:bit is shaken.
It randomly either shows a dream or a nightmare.
A dream:
The light flash from red, orange, yellow, green, blue 4 times with a pause of 200 milliseconds between them. They then clear.
A nightmare flashes quickly and randomly between red and white. The brightness is also random:
I should make my program more efficient by putting clear and show out of the if statement!