Skip to main content

1.2

Major VersionM

by Pete Prodoehl

Introduction

Connect a NeoPixel Stick and a Pushbutton to a Bit Board and control them with code.

We'll explore how to control an Addressable RGB LED Strip (also called "NeoPixels").

Video Overview

Featured Document

  1. The magical thing about these “Individually Addressable” LEDs is that you don’t have to connect each LED to an individual pin on your micro:bit, you just need one signal wire along with power (Positive and Negative) to light things up. So let's get connected! If you turn the NeoPixel Strip over you'll see labels for the three pins. You should see IN, VCC, and GND. Use the Crazy Circuits Ribbon Cable to connect the NeoPixel Strip to the Bit Board.
    • The magical thing about these “Individually Addressable” LEDs is that you don’t have to connect each LED to an individual pin on your micro:bit, you just need one signal wire along with power (Positive and Negative) to light things up.

    • So let's get connected! If you turn the NeoPixel Strip over you'll see labels for the three pins. You should see IN, VCC, and GND.

    • Use the Crazy Circuits Ribbon Cable to connect the NeoPixel Strip to the Bit Board.

    • The end with S1, +, and - can plug directly into the Pin 13 row (make sure S1 goes into 13) and the other end should plug into the NeoPixel Strip as shown.

    • We only need three wires for the NeoPixel Strip so you can leave S2 (the Orange wire) unconnected.

    • We'll also connect a button using Maker Tape. Connect it to Pin 5 and GND. (Polarity does not matter with these buttons.)

  2. To mount the NeoPixel Stick in place we used our NeoPixel Beam Holder with a long Technic Beam and two 1x1 LEGO bricks. You can always use rubber bands, tape, or some other method. The important thing is to make sure the connector is on the left hand side so the number index for the NeoPixel strip makes sense.
    • To mount the NeoPixel Stick in place we used our NeoPixel Beam Holder with a long Technic Beam and two 1x1 LEGO bricks.

    • You can always use rubber bands, tape, or some other method.

    • The important thing is to make sure the connector is on the left hand side so the number index for the NeoPixel strip makes sense.

  3. If you've never used a micro:bit before you'll want to check out this guide:  Bit Board V2 Setup and Use
    • If you've never used a micro:bit before you'll want to check out this guide: Bit Board V2 Setup and Use

    • We're going to load the following code for our NeoPixel Back and Forth program: https://makecode.microbit.org/_aYfabuKuy...

    • In our forever loop we're going to check for a button press, and use it to change a variable called theDirection to either 1 or 0.

    • Our forever loop also calls the function movePixels which will look at the theDirection value and use it to set the shiftVal and startIndex variables.

    • Those two variables are all we need to change the direction the pixel moves in.

    • Once the code is loaded it should start running immediately.

    • You can power the micro:bit via the USB cable you used to load the code or you can use a battery pack plugged into the Bit Board.

    • You'll see the pixel move from left to right...

    • Press the button down and the pixel should reverse direction.

    • If you hold down the button the pixel will just go back and forth repeatedly.

    • Again, we recommend you see CH4-D - Button Toggle Better for a more advanced "toggle" example.

    • Follow along with our recorded Live Stream!

    • You can watch the full video of us walking through this project, along with explaining and exploring the code: https://youtube.com/live/8EJiYAkb8qk

Finish Line

Pete Prodoehl

Member since: 3/4/20

1,840 Reputation

424 Guides authored

0 Comments

Add Comment



View Statistics:

Past 24 Hours: 0

Past 7 Days: 0

Past 30 Days: 1

All Time: 33