LED strips with Micro:bit

One of the funnest things to play with are LEDs. These are a type lights. They can be single colour or you can code them to be any colour you like. The type where you can select their colour are called RGB. You can get individual LED or multiple ones arranged like a strip or sometimes like a ring

The Micro:bit can have more blocks that the ones you see. You have to add them as extensions. There are many extensions available. You can add them by clicking on "Extensions" like this


The one we need for LED strips is called "neopixel"

Once you add the "neopixel" extension there will be a new category with new blocks to control your LED strip. You can see them in the following picture


To test it do the code below. With the first block we are telling the Micro:bit that there is an LED strip connected to pin 0 with 7 LEDs. Every time you connect something external to the Micro:bit you connect it to the pins, so it is important to let it know exactly what pin is connected to. There 3 pins that are available to connect things (0, 1 and 2). The two pins on the right are voltage (3V) and Ground (GND). Notice in the code how every time you make a change to the strip you need to put "strip show" so that the change happens

Even if you don't have an LED strip you can still see what happens in the simulator


In the video below you can see it in action





Comments