Materials

Micro:bit

Crickit

LED strip

USB cable

Chromebook, Laptop or Computer

Tools

mini screw driver

Difficulty

Mechanical:  none

Coding and Electrical:  easy

Construction:  none

Adding LEDs to a Project

Adding LEDs to a project will grab people’s attention.  Use them as to illuminate dark areas, as signage, or just for decoration.

 

Connecting the LED strip

 

NeoPixels are connected on three terminals labeled “NeoPixel”.  GND is connected to GND.  +5V to 5V, and the arrow terminal to the Din pin on the NeoPixel.  We are working with the Micro:bit version of the Crickit but the Circuit Playground Express version is similar.

 

The wires are held in by screw terminals.  In this example the black wire is G (ground), green wire is  (signal wire), and the red wire is 5v (power).   Using a mini screwdrivers, loosen the screws high enough to fit the wires in, put the wires in and tighten the screws back down to hold the wires in place.   If you notice in the picture on the left the screws are higher and the terminals are ready for the wires.  Do not remove the screws, just loosen them enough to fit the wires under and in the hole.  In the picture on the right you will notice the screws are tight and the wires are secured.

 

Coding your LED strip

You will need to add the NeoPixels extension to MakeCode to control NeoPixels. 

Start by opening the MakeCode editor
for Micro:Bit:     https://makecode.microbit.org

 

 

Start a “New Project” or open an existing project

Name the project whatever you want and click “create”

 

On the middle menu click Advanced and then Add Extension

 

 

Type “neopixel” into the search box at the top of the extensions page.

 

Click on the Neopixel extension to add it.

 

 

You should now have a block group added to the middle menu called Neopixel which will have the blocks you need for NeoPixel control.

 

 

Example Code

 

 

The Crickit connects the neopixel LED strip to pin 16 on the Micro:bit so in this example we are setting up the neoPixel strip to use pin 16.  Note we are setting this strip for 24 LEDs, you will need to modify this value with the amount of LEDs your strip has. 

The On Start start sets a variable named “strip” as 24 neopixels attached to pin 16 then it calls that “strip” to be rainbow patterned.

The Forever section then tells that strip, in order, to rotate the rainbow pattern through the 24 leds, show the change, pause for .25 seconds to slow it all down, and then repeat forever.