Introduction
Connect a Distance Sensor to a Bit Board and view the output using a NeoPixel Strip.
Video Overview
Featured Document
-
-
We'll connect the Distance Sensor with a Crazy Circuits Ribbon Cable using all four wires.
-
Plug the three-wire connector of the Crazy Circuits Ribbon Cable into the row with Pin 13 on the Bit Board. The wire colors should match the pin header colors, with S1 (yellow) going to the yellow pin.
-
Next, plug S2 (orange) into Pin 14. (S2 is separated from the three-wire connector to allow you to plug it into another row.)
-
To the Distance Sensor plug + (red) into VCC; S2 (orange) into TRIG; S1 (yellow) into ECHO; and - (black) into GND.
-
-
-
We'll connect the NeoPixel Strip with a Crazy Circuits Ribbon Cable using just three of the wires.
-
Plug the three-wire connector of the Crazy Circuits Ribbon Cable into the row with Pin 1 on the Bit Board. The wire colors should match the pin header colors, with S1 (yellow) going to the yellow pin.
-
We do not need to plug in the S2 (orange) wire, so you can leave it disconnected.
-
To the NeoPixel Strip plug S1 (yellow) into IN; + (red) into VCC; and - (black) into GND.
-
(Again, we do not need to plug in the S2 (orange) wire, so you can leave it disconnected.)
-
You should now have the Distance Sensor and NeoPixel Strip connected to the Bit Board.
-
-
-
We used a 3D printed part we designed to hold the Distance Sensor and NeoPixel Strip in place on the LEGO baseplate.
-
A few Technic pins, a Technic beam, and some LEGO bricks are all that is needed.
-
Alternately you can use some LEGO bricks and a rubber band or tape to hold the sensor in place. (But don't use anything conductive!)
-
3D print your own Distance Sensor Holder with Holes and Rover NeoPixel Beam Holder. (They're the same ones we use in our Bit Board Rover Kit).
-
-
-
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 Distance Sensor NeoPixel Meter program: https://makecode.microbit.org/_VHHb7Jhik...
-
In the on start block we'll set up our NeoPixel Strip and five different "ranges" we can use to turn on just some of the NeoPixels.
-
In our forever loop we'll get the value of the distance and then use that in an if/else block to determine which range we want to choose.
-
The final else will set range0 as the chosen one, which means none of the NeoPixels will be turned on.
-
Finally, once we've set our range we'll call strip show and strip clear to send the data from the micro:bit to the NeoPixel Strip.
-
-
-
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.
-
Move your hand (or a flat object) in front of the sensor. As you get closer you'll see more NeoPixels light up.
-
-
-
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: Chapter 36 - Distance Sensor NeoPixel Strip
-
