Lesson 12 – Multiple Devices

Hummingbird Components

Second micro:bit and a small battery pack to power it, 1 Tri-Color LED, 1 Rotation Servo, 1 Position Servo, 1 Distance Sensor

Python Concepts

Object-oriented programming

Teacher Materials

Get Access

You can connect up to three Hummingbird Bits or micro:bits with the BlueBird Connector or BirdBrain Brython! This means that you can create robots that interact with one another. In this module you will use a second micro:bit to control the Hummingbird.

Download this file onto the second micro:bit.  

The BlueBird Connector will show all the devices that are available. To connect the Bit and the micro:bit, just click on both of them.

Both devices should show up in the Connected section. One will be labeled with an ‘A’ and one with a ‘B.’

To connect a second device with BirdBrain Brython, click the expand button. Then click Find Robots and select the second device.

Both devices should show up in the Connected section. One will be labeled with an ‘A’ and one with a ‘B.’

In all the previous lessons, you have been declaring an object of type Hummingbird. This object enables you to access all the Hummingbird methods. If you connect two Hummingbird Bits in the BlueBird Connector, you can declare two Hummingbird objects.

You have connected one Hummingbird and one micro:bit, so you need to declare one Hummingbird object and one Microbit object. To do this, you must import the Microbit object from the HummingbirdBit library. Note that the letter of the device (A or B) is given in the BlueBird Connector. In the picture above, the Hummingbird is device A and the micro:bit is device B.

The Microbit object enables you to access all of the methods for the micro:bit, including setDisplay(), print(), getButton(), etc. For more information on which methods you can use with Microbit objects, please see the Hummingbird library documentation.

Exercise 1

Try out this code. Make sure the letters in your declarations match the letters of the devices in the BlueBird Connector. This code should enable you to use the second micro:bit to turn the Hummingbird’s tri-color LED on and off. The program will run until you place the second micro:bit in the “Screen down” position. Then modify this code so that the second micro:bit also turns a rotation servo on and off.

Exercise 2

For this exercise, you will need your code from Exercise 6 in Lesson 10. Modify this code so that tilting the second micro:bit controls the Hummingbird buzzer, tri-color LED, and position servo.

Exercise 3

Write a program that uses the compass of the second micro:bit to control the Hummingbird. Use your imagination to figure out what the Hummingbird should do when the compass is pointed in different directions!

Exercise 4

You can also use the Hummingbird to control the second micro:bit. Write a program that prints “CLOSE” on the second micro:bit when an object is less than 30 cm from the distance sensor. Otherwise, the program should print “FAR” on the second micro:bit. The program should run until you press button A on the Hummingbird micro:bit.

Extra Challenge

Team up with another person or team to try connecting two Hummingbirds to the BlueBird Connector. Write a program that uses the sensors of each Hummingbird to control the outputs of the other. The sensors of Hummingbird A should control the outputs of Hummingbird B, and vice versa. The code below should help you get started.

Extra Challenge

Try building a rover and using a second micro:bit to control it!

Back to Top