Skip to main content

1.1

Major VersionM

by Pete Prodoehl

Introduction

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

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

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

    • 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 360 Servo Button Spinner program: https://makecode.microbit.org/_fyhFiEguq...

    • We'll get our button all set in the start block by setting it to up so when the button is shorted to GND (ground) or "pulled down" we can read the state.

    • For this program everything happens in the forever block once the button is pressed.

    • When the button is pressed we'll set the spinTime variable to a value between 200 and 2000, then start the motor spinning, and wait for the amount of milliseconds specified by spinTime.

    • When the pause is over we'll set our speedValRev to 100 and then do a for loop where we slowly lower the speed of the motor.

    • Finally, we'll stop the motor completely with the turn off motor block.

    • Once the code is loaded it should start running immediately, though nothing will happen 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.

    • Press the button and the servo will spin for a. random amount of time before it starts to slow down and eventually stop.

    • This could be used as a electronic version of a game spinner. Instead of flicking the spinner with your finger you can press a button!

    • 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/HcgJlJ8a2KI

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

All Time: 19