Introduction
Connect a Crazy Circuits NeoPixel and a Potentiometer to a Bit Board and control them with code.
We'll explore how to control an RGB LED (a "NeoPixel") using a potentiometer.
Featured Document
-
-
We'll use Maker Tape to connect the NeoPixel and the Potentiometer to the Bit Board on a LEGO baseplate.
-
We'll connect our Potentiometer to Pin 1, Ground (GND), and 3.3v BUT! We're going to use the "gutter" between the LEGO baseplate studs so we can have two layers of tape that do not touch.
-
See the photos to show how this works. It's a technique we'll use for certain projects. It can also be used when you're tight on space for tape paths.
-
Once the Button is connected we'll need to connect the NeoPixel. One side goes to Ground (GND) and the other side to 3.3v
-
We'll then connect the center pin labeled DI (for Digital Input) to Pin 0, which will control the NeoPixel. Run the tape on top of the studs so it does not touch the tape connected to the Potentiometer.
-
You'll notice the Ground on the Bit Board (as well as the NeoPixel and other Crazy Circuits components we'll use) is color coded White.
-
The 3.3v hole on the Bit Board is labeled and is actually two holes right next to each other on the Bit Board. (There is a small line showing the connection between them.)
-
-
-
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 Potentiometer R program: https://makecode.microbit.org/_aiqUpdW19...
-
We'll use the Potentiometer to adjust the brightness of the NeoPixel's level of Red.
-
Since the NeoPixel expects a value between 0 and 255 we'll use the map function to change the 0-1023 scale from the potentiometer to 0-255 for the NeoPixel.
-
Note that we are using the round function so we get a whole number (an integer) and not a floating point (decimal) number.
-
-
-
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.
-
Turn the small blue knob on the Potentiometer and you'll see the brightness of the NeoPixel change. (It will only show red for this example.)
-
Turning fully anti-clockwise should make the LED so dim it appear to be "off" and turning the knob fully clockwise should set it to the brightest it can go.
-
-
-
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/KBatTBnfasY
-
