A NeoPixel is an individually addressable, colour-changing LED  that can be controlled from a single pin on the micro:bit. NeoPixel is the brand name given to the WS2812 Integrated Light Source. NeoPixels can be chained together and are often supplied as tapes or in accessories that contain multiple NeoPixels.


Connecting NeoPixels to the micro:bit

Unless you are using a micro:bit accessory that has built-in Neopixels, you will need to connect the NeoPixels to your micro:bit using P0, 3V GND to the respective pins on the strip.


micro:bit connected to NeoPixels


Programing NeoPixels in MakeCode

Add the extension

To use NeoPixels, you will need to add the NeoPixel extension to MakeCode. From the settings wheel ⚙️ in MakeCode, choose Extension and select the NeoPixel extension from the list



Initialise the NeoPixels

To be able to turn a NeoPixel LED on or off, you must first initialise the NeoPixel class. This means that you are telling MakeCode that a number of NeoPixels exist and that they are Red, Green, Blue (RGB) responsive. You can do this by adding a 'set strip to...` block to the `on start`block. Once you have done this, you can then call the show method on this class.




This video shows the process of initialising a Neopixel in the Makecode editor.



Program the NeoPixels to show a rainbow of colours

This example uses 12 Neopixels to display a rainbow of colours, rotating the colours every 200ms.