NeoPixel Projects with the MicroBit

Connecting a Neopixel to a MicroBit is easy, rewarding, and illuminating.  This tutorial will walk you through the steps.  We’ll also show you three easy things to do: Make a Color, Rotating Rainbow, and Inifinty (with two microbits).

Materials

You will need to make three connection to the Microbit using the alligator clips.  They will be at ground, 3V, and one of the I/O pins.  Here we use Pin 0.

The ends of the alligator clips should connect to wires that will connect to the NeoPixel.  On the back of the NeoPixel, you can see some connections. You will connect to them like this:

  • Microbit Ground to NeoPixel Ground
  • Microbit 3V to NeoPixel PWR +5V
  • Microbit Pin 0 to NeoPixel Data Input

There are 2 Grounds and 2 PWR +5Vs on the NeoPixel.  You can use either one.

Once they are connected, you are good to download a program.  To get the NeoPixel package on the Microbit you will need to click on Advanced and Add A Package on the block menus.

You get a package selector where you can add some kind of package to the Microbit.  You can type NeoPixel into the search bar, or you may see it as an available package.

After this you are cleared to write your first program.  I have three here.

Make a Color

A good test is to simply turn it on and make it show a color.  To do this, at startup we create a variable called ‘ring’ that is the NeoPixel on Pin 0 with 24 RGBs.  Then in the forever loop, we ask it to set the ring equal to a color, and show it.

Rotating Rainbow

This was a class favorite.  Here we again make a variable called ring, and make it show a rainbow.  Then in the forever loop we have it rotate the pixels by one repeatedly, so it rotates.

Infinity

This was presented as a challenge, and two of my students made quick work of it.  Two MicroBits and two rings were set side by side.  They were set to the color blue, and a red one loops around them making an infinity symbol.  The two microbits communicate via radio.  One is a sender and one is a receiver.  This was written by our campers, Ryan and Sid.

Sender

Receiver