Micro:bit With Hummingbird

by hypergami in Circuits > Microcontrollers

7837 Views, 4 Favorites, 0 Comments

Micro:bit With Hummingbird

IMG_7249.jpg

The Hummingbird board (by Birdbrain Technologies) can control LEDs, a variety of sensors (including light, dial, distance, and sound); servo motors, and other extensions. This Instructable will show you how to use a micro:bit in a Hummingbird board to power two kinds of servo motors.

Supplies

  • Hummingbird Controller (Birdbrain Technologies)
  • BBC micro:bit and usb connector cable
  • Power supply with barrel jack end (we use a battery pack in this example)
  • Servo motor(s): rotational and/or positional

Set Up the Hummingbird

IMG_7251.jpg
IMG_7264.jpg

Our first example will show you how to operate a positional servo from the Hummingbird.

The long slot to the left of the board is where to insert the micro:bit. Insert the micro:bit with the LEDs facing up. Insert the servo motor into the port labeled "1" on the right side of the board. Note that the port has three pins - labeled S, +, -. Be sure to orient your motor so that the colors of your wires line up with the correct pins. The black wire on your motor usually indicates "ground" and should plug into the "-" pin.

Connect power to the board with the barrel jack. We are using a battery pack in this example, but you can also use a power adapter.

Add the Hummingbird Library to MakeCode

Load Hummingbird library into MakeCode

It is possible to use a variety of languages and platforms (including BirdBlox, Python, and Java) to program the micro:bit to run the Hummingbird board. This Instructable uses MakeCode.

Open MakeCode in a web browser and start a new project. If you are brand new to MakeCode, it would help to work through the tutorials on the MakeCode site before continuing.

If you are new to micro:bit, start here.

Load the Hummingbird library. A library is a pre-written set of instructions written for specific uses. The Hummingbird library provides pre-made code blocks for using the Hummingbird. Click the video above to see a screen animation of how to add the Hummingbird library to MakeCode.

  • Click the Advanced tab in the menu.
  • Select Extensions
  • On the Extensions screen, do a search for "Hummingbird".
  • Click on it to add the Hummingbird library to your MakeCode project.
  • When you return to the MakeCode screen, you'll see the Hummingbird library in the menu.
  • Optional: minimize the window with the micro:bit simulator - we will not use the simulator with the Hummingbird.

Operate a Position Servo With the Hummingbird

Program a Hummingbird servo
Hummingbird with Position Servo

A position servo is a motor where you can set the position of the propellers and move them around by specifying positions in degrees. The position servo we are using here uses values from 0 to 180 degrees.

Setup:

  • Move a Start Hummingbird block into the micro:bit "on start" block.

Now we need to tell the position servo (also known as a 180 degree servo) to move back and forth.

  • In the micro:bit "forever" block, we will first move a Hummingbird command to set the servo in port 1 to 0 degrees.
  • Add a Pause block for 1000 milliseconds (1 second). Note that the Pause blocks are in the Basic micro:bit menu.
  • Now, add a Hummingbird command to move the servo in port 1 to 180 degrees.
  • Add another Pause block for 1000 milliseconds.
  • These commands are in a "forever" block, so they will repeat until you give another command or turn the motor off.

Download the code to your micro:bit.

The second video shows how to connect the Hummingbird, micro:bit, power, and motor.

Operate a Rotation Servo

Hummingbird Rotation Servo
Running a rotation servo with Hummingbird
rotation code.jpeg

The Hummingbird can also power a different kind of servo motor called a continuous (or rotation) servo.

This type of motor rotates at different speeds in either direction. The rotation servo uses the same servo ports on the Hummingbird board as the position servo.

Plug the rotation servo into port 1. Be sure that the ground (black) wire plugs into the "-" pin.

A rotation servo uses a speed and a direction.

  • Be sure to import the Hummingbird library (step 2) and to add the "Start Hummingbird" command in the "Start" block.
  • Drag the Hummingbird Rotation Servo block into the "forever" block.
  • Select "1" because we have the servo plugged into port 1.
  • Enter a value for the speed at which you want the Hummingbird to run. 100% is the fastest the motor will go. 0% is off.
  • A positive number moves the motor clockwise and a negative number moves the motor counter-clockwise.
  • In this example, we first run the motor clockwise at 100% speed, pause, and then run the motor counterclockwise at 100% speed, pause, and continue the pattern.
  • Download the code to the servo and watch the behavior of the motor.
  • Be sure to have an external power supply (power adapter or battery pack) hooked up to the barrel jack of the Hummingbird, or there will not be enough power to run the motor.
  • Try varying the speed, pause length, and direction of the motor.

Operate a Position Servo and a Rotation Servo at the Same Time

MakeCode Two Servos.jpeg
Running two different servos with Hummingbird

In this example, we will run a position servo and a rotation servo at the same time.

Plug a position servo into port 1.

Plug a rotation servo into port 2.

In the forever loop, we will set the position servo to 0 degrees and move the rotation servo at 100% speed in the clockwise direction. We will pause 2 seconds, and then move the position servo to 180 degrees, and reverse the direction rotation servo to turn at 100% speed in the counterclockwise direction.

More to Explore ...

The Hummingbird can control up to four motors at a time. See if you can make use of four motors.

The Hummingbird can use sensors as input. Use a light sensor or a sound sensor to turn a motor on or off.

Add some LEDs to light up your project.

Visit these sites to learn more about Hummingbird Robotics, MakeCode, and micro:bit!

We use Hummingbird with micro:bit to power motors and add functionality to paper machines from our Paper Mechatronics projects. Check out the website to build your own machines and then hook them up to lights, sensors, and servo motors. Have fun!

This material is based upon work supported by the National Science Foundation under Grant No. IIS-1735836. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.

This project is a collaboration between The Concord Consortium, University of Colorado, Boulder, and Georgia Tech University.