Introduction
Connect a potentiometer to a Bit Board and control the micro:bit's built-in LED matrix.
We'll explore how we can use a potentiometer as an input for the micro:bit
Video Overview
Featured Document
-
-
We'll use Maker Tape to connect the Potentiometer to the Bit Board on a LEGO baseplate.
-
We'll need to connect one side of the Potentiometer to Ground (GND) and the other side to 3.3v
-
We will then connect the center of the Potentiometer to Pin 0. (Note that Pin 0 is an analog pin, which we'll need for the Potentiometer.)
-
The other analog pins are 1, 2, 3, 4, and 10. See this chart for a pinout diagram: https://makecode.microbit.org/device/pin...
-
You'll notice the Ground on the Bit Board 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 Potentiometer Pixel Smooth program: https://makecode.microbit.org/_gutWHvAia...
-
For this code we've added a variable to track the previous value of the Potentiometer. This allows us to compare it to the current value, and only clear the screen and plot a new pixel if the value has changed.
-
While our code is a little more complicated, it becomes more efficient, and only executes certain commands based on conditions.
-
-
-
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 should see a single pixel move left or right.
-
This time we plot the pixel (after clearing the screen) only after we check if the value from the Potentiometer has changed from what its previous value was.
-
-
-
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/jN7oP8TrU8k
-
