For World Book Day my son dressed up as the BFG. So, of course, I had to make him a micro:bit dream jar!
— Lorraine Underwood (@LMcUnderwood) February 28, 2017
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.
I used white crocodile clips so they would be camaflouged in the bubble wrap.
- 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.
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!