Introduction
Connect a Thumbstick to a Bit Board and use it to control a 270˚ Servo.
Video Overview
Featured Document
-
-
We'll connect the Thumbstick 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 0 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 1. (S2 is separated from the three-wire connector to allow you to plug it into another row.)
-
To the Thumbstick plug - (black) into GND, + (red) into +5V; S1 (yellow) into VRx; S2 (orange) into SW.
-
We won't plug anything into VRy pin for this example.
-
-
-
The 270 Degree Servo Motor has a 3-wire connector on the end that can plug directly into the pins on the back of the Bit Board.
-
Make sure the Orange Wire from the servo is closest to the number 13 for the Pin 13 column.
-
Then the Brown Wire should be closest to the micro:bit (in the - row) and the Red Wire will be in the middle (the +5v row).
-
-
-
We used a 3D printed part we designed to hold the Thumbstick in place on a LEGO baseplate.
-
We attached two 2x4 LEGO Bricks to the bottom of the 3D printed holder to allow it to snap onto the LEGO Baseplate a bit easier.
-
Alternately you can try to use some LEGO bricks and some rubber bands to hold the sensor in place, or just hold it in your hand.
-
3D print your own Thumbstick Sensor Holder.
-
-
-
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 Thumbstick 270 Servo Speed program: https://makecode.microbit.org/_XsAW55CwT...
-
In the on start block we'll disable the LED matrix and set Pin 1 to pull up, as we'll attach this to the button on the Thumbstick.
-
In the first forever loop we'll read analog Pin 0 and map the value from 0 to 1023 to a scale going from 150 to 0. We will assign our value to a variable named delayVal.
-
In the second forever loop we will use two for loops to sweep the servo back and forth, and our delayVal variable will be used to change the speed of movement.
-
We are using two different forever blocks so that we can continually update the delayVal by reading the Thumbstick and then apply that value in the second forever block while the for loops are running.
-
-
-
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.
-
The servo will start moving as soon as the code starts running, sweeping back and forth.
-
Move the Thumbstick left and right and you'll see the speed of the servo change. (Left will slow it down, right will speed it up.)
-
Chapter 24 has a few notes on using 270 Servos with the Bit Board and some MakeCode limitations: CH24-A - Servo Sweep
-
-
-
Follow along with our recorded Live Stream!
-
(We'll add the video to this step after we do the stream!)
-
