Skip to main content

1.0

Major VersionM

by Pete Prodoehl

Introduction

Connect a Distance Sensor to a Bit Board and view the output using a NeoPixel Strip.

Video Overview

Featured Document

  1. 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.)
    • 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.

  2. 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.
    • 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.

  3. 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!)
    • 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).

  4. 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 Distance Sensor NeoPixels Warning program: https://makecode.microbit.org/_8V4PDcD4K...

    • In the on start block we'll set up our NeoPixel Strip and a variable called myLimit with a value of 20.

    • In our forever loop we'll check if the distance is lower than myLimit and if so we blink our NeoPixel Strip, first setting it to red, then setting it to black.

    • In this case setting the NeoPixel Strip to black has the effect of turning the strip off, or "unlighting" the NeoPixels.

    • If the distance is greater than myLimit we do not blink the NeoPixel Strip. And since the last state they were in was off the NeoPixels will be off.

    • 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. When you are within 20cm of the sensor the NeoPixel Strip should start blinking.

Finish Line

Pete Prodoehl

Member since: 3/4/20

2,140 Reputation

452 Guides authored

0 Comments

Add Comment



View Statistics:

Past 24 Hours: 0

Past 7 Days: 13

Past 30 Days: 14

All Time: 14