Micro:Bit Rainbow Lights

BBC Micro:Bit

ZIP Halo for the BBC Micro:Bit

AAA battery holder for ZIP Halo

Three AAA

This week’s challenge will show you how to use a Micro:Bit to have a rainbow at home. Maybe even put it in your window!

Go to the BBC Micro:Bit website (https://makecode.microbit.org/) 

Open a new project by clicking the ‘New Project’ button

Grab a ‘show icon’ block from the ‘Basic’ menu (it at the top of the sections) and put it in the ‘On Start’ block.

Drag the block from the menu and put it in the ‘On Start’ Block

Go to the ‘Advanced’ Section of the Editor and find the ‘Extensions’ area. Click on the ‘Extensions’ area. You will be met with this screen:

Click on ‘neopixel’. There now is a ‘neopixel’ button on the menu.

Get an ‘On Button Pressed’ piece of code from the ‘Input’ Section. 

Go to ‘neopixel’ and get a ‘strip show rainbow from 1 to 360’ block  and place it in the ‘On Button A Pressed’ block.

Grab another ‘On Button Pressed’ block from the ‘Basic’ menuand put it in your code. It will go yellow when you drop it into your code. Why is that?

It’s because you already have one in your code. Click on the ‘A’ in the yellow ‘On Button Pressed’ block and from the dropdown menu select ‘B’.

Click on ‘neopixel’ and find the top piece of code in the menu. Grab it and put it in the ‘On Start’ section in your code.

Go to ‘neopixel’ and find a ‘Strip Clear’ block. Grab this and put it in the ‘On Button B Pressed’ block. Find the ‘Strip Show’ block in ‘neopixel’ an put this in the ‘On Button B Pressed’ block after the ‘strip clear’ block.

At the bottom of the page change the name from ‘Untitled’ to ‘Pixel Light Project’. In the left bottom corner press download

Get your cable and plug the large end into your computer in a USB hole (they are about 3mm by 1cm large.) Plug the other end into the top(where the Micro:Bit Look for this file (It will be called ‘microbit-Pixel-Light-project.hex’) In your downloads folder and put it onto your Micro:Bit. Don’t open a new folder!

Get a small crosshead screwdriver and align your Micro:Bit and Halo and screw all the screws into the the Halo and the Micro Bit. Put the AAA batteries in the holder (ensuring the polarities are in the right way) and plug the Battery Holder into the Halo.  Make sure you plug it into the Halo. Flick the on-off switch to on and

Operation:

Press button ‘A’ to turn the lights on and press button ‘B’ to turn them off.

This is the Javascript code:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.