Skip to main content

1.3

Major VersionM

by Pete Prodoehl

Introduction

Connect a 270˚ Servo to a Bit Board and control it with a Pushbutton and code.

We'll explore using a momentary push button (and some code) to control the movement of a servo motor.

Video Overview

Featured Document

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

    • Connect the Button with Maker Tape, with one side to Pin 5 and the other to GND.

  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 Servo Selector List Better V1 program: https://makecode.microbit.org/_dxJ0jxiC4...

    • We've added a slight improvement to the previous version... This time we keep track of the last angle in the angleValPrev variable so we can check if the new angle is the same as the last one.

    • This means we won't get the same value twice in a row, which would result in the servo not moving.

    • We use a simple while loop and keep getting a new value for angleVal until we have one that is not equal to angleValPrev.

    • Once the code is loaded it should start running immediately, but the servo won't move until you press the button.

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

    • When the button is pressed the servo will move to a position.

    • But this time you won't run into the "bug" where you press the button and the servo does not move.

    • A "bug" is a feature in a computer program that causes undesired consequences. If you press the button and the servo does not move when you expect it to that would be considered a bug.

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: 1

Past 30 Days: 1

All Time: 29