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 V2 program: https://makecode.microbit.org/_fuaU6bXKP...

    • We have two more improvements to our code...

    • The first one is simple. Where we choose our random value from the list we now use length of array instead of a hardcoded value for the length of the list. This allows us to easily change the length of the list without having to change the pick random values.

    • The second improvement is a little more complex. One of the bugs in the previous guide allows you to just press and hold the button and the servo would continually move and never stop...

    • This time we're tracking when the button is pressed and when it is released. This allows is to only move the servo when the button is released.

    • 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 and then released the servo will move to a position.

    • With this version holding down the button continually will have no effect. The servo will only move after the button has been pressed and then released.

Finish Line

Pete Prodoehl

Member since: 3/4/20

1,840 Reputation

424 Guides authored

0 Comments

Add Comment



View Statistics:

Past 24 Hours: 1

Past 7 Days: 1

Past 30 Days: 3

All Time: 30