Skip to main content

1.2

Major VersionM

by Pete Prodoehl

Introduction

Connect a 360˚ Servo to a Bit Board and control it with a Potentiometer and code.

We'll explore code to control the movement of a continuous rotation (360 degree) servo motor using a potentiometer.

Video Overview

Featured Document

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

  2. 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 360 Servo Potentiometer Both Ways program: https://makecode.microbit.org/_XCMggoAK9...

    • We'll run an analog read pin on Pin 0 and assign that to a variable named potVal.

    • They we can check if potVal is less than 412 or greater than 612, or neither!

    • If potVal is less than (or equal to) 412 we'll spin the motor one way, with the speed increasing the farther anti-clockwise we turn the Potentiometer knob.

    • If potVal is greater than (or equal to) 612 we'll spin the motor the other way, with the speed increasing the farther clockwise we turn the Potentiometer knob.

    • If the value of potVal is in the "dead zone" (between 413 and 611) we'll stop the motor so it does not move. This allows us to have a central position where the motor is stopped, and then choose the direction of spin (and affect the speed) when we turn the knob either direction.

    • Once the code is loaded it should start running immediately, but the motor may or may not move depending on the position of the Potentiometer knob.

    • You can power the micro:bit via the USB cable you used to load the code, but now that we are using servos we recommend using a battery pack plugged into the Bit Board.

    • The Blue Pins on the Bit Board provide extra power (5 volts instead of 3 volts) by boosting the voltage coming from the battery pack. This helps improve servo performance, especially with multiple servos.

    • With the Potentiometer knob in the center the motor should not move.

    • Turn the knob anti-clockwise slowly and you'll see the motor increase in speed the more you turn it.

    • Turn the knob back to the center to make the motor stop moving, and then turn the knob clockwise slowly and you'll see the motor turn the other direction and increase in speed the more you turn it.

    • 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/1H9jjAUFHAI

Finish Line

Pete Prodoehl

Member since: 3/4/20

1,840 Reputation

424 Guides authored

0 Comments

Add Comment



View Statistics:

Past 24 Hours: 0

Past 7 Days: 0

Past 30 Days: 23

All Time: 23