Microbit Sensors & Circuits
Advanced
60 mins
190 points
What you need:
  • Microbit
  • LED Strip with crocodile clips

LED Stacking

In this step-by-step lesson, you'll create an interactive LED stack using a Microbit project. You'll add the neopixel extension, set up the LED strip, create variables, and develop functions to control the LED stack. By programming buttons, you'll be able to increase or decrease the stack. Finally, you'll download your code and test your LED stack.

1 - Create a new Microbit project

To get started create a new Microbit project.

makecode.microbit.org

2 - Add the neopixel extension

To access the blocks we need to program the LED strip, you need to add the neopixel extension to your project.


3 - Setup the LED Strip

To be able to interact and program the LED strip we will need a variable that stores the strip.

Add the following code to your project. We set the value to be 30 as there are 30 LEDs on the strip.

4 - Create an amount variable

We need a variable to store the amount of LEDs in our stack.

Create a variable called amount.

5 - Create a function to show the stack

At several times we will want to show the stack of LEDs lit up. Rather than add the code to light up the stack each time, let's create a function that has the code to light up the stack. We can then call this function anytime we want to run that code.

Create a function called "showStack".

Join our club 😃

To view the remaining 4 steps and access hundreds of other coding projects please login or create an account.

Copyright Notice
This lesson is copyright of . Unauthorised use, copying or distribution is not allowed.
🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more