**You must have a BLE adapter to use your Hummingbird Duo with BirdBlox. Purchase it here.**

Before you can build an awesome robot with your Hummingbird, you need to know how to use all the parts. This lesson will first show you how to use the Hummingbird outputs, the lights and motors. These components are called outputs because programs in BirdBlox send commands to them to make something happen. Then you will learn how to use the Hummingbird inputs, the sensors that provide information to the robot about its environment.

Keys Available

Keys are available to educators.

Get Access

Getting Started

Start by watching the videos below.

The first will show you how to attach components to the Hummingbird board, and the second will demonstrate how to connect to the Hummingbird from the BirdBlox app.

Connect the AC power adapter to your Hummingbird and the wall socket.

You may see a dialog box that asks you to open an existing program or create a new one. Tap New and give your program a name such as “test.” As you write your program, it will be saved automatically with this name.

To connect to your Hummingbird, tap the Hummingbird Connection icon at the top of the screen. Then tap Connect Device. Select your Hummingbird from the list of devices. Each Hummingbird has a three word name like “Hopping Mountain Zebra.” If you don’t know which Hummingbird is yours, just pick one.

Once BirdBlox is connected to a Hummingbird, you will see a steady blue light on the bluetooth adapter. If you have multiple Hummingbirds, this will tell you which one you have connected to. Once you know a Hummingbird’s name, it is useful to write the name on a piece of masking tape and tape it to the top of the Hummingbird board. This will make it easier to connect to the device in the future.

Programming in BirdBlox

This is the main BirdBlox window. To write a program, you will drag blocks from the Blocks area on the left to the Scripts area on the right. In BirdBlox programs are also called scripts. You can use BirdBlox to write scripts that use the Hummingbird and the sensors of the tablet. For example, you can write a program to control a robot based on how you are tilting the tablet.

When BirdBlox is connected to a Hummingbird, there will be a green circle by the Hummingbird Connection icon, and the blocks on the Robots menu will be teal. If the robot becomes disconnected, the circle will turn red and the blocks on the Robots menu will be gray.

The Blocks area in BirdBlox contains six different menus – RobotsTabletSound, etc. Click on the different menus to get an idea of the blocks that they contain. All the Hummingbird blocks are located in the Robots menu. This video will show you the basics of how to write a program in BirdBlox.

Saving and Loading Projects

In BirdBlox, projects are saved automatically to the memory of the tablet. They will only be accessible on the current device and will be deleted if the app is uninstalled. To transfer a project to another device or back it up more securely, you can export the program. This process is summarized in the video below.

To create a new project, tap on the File icon.

From the File screen, you can open an existing file or create a new project with the New button. To rename a file, tap the pencil beside the project name.

To delete or duplicate a file, tap the dots beside the file name. When you duplicate a project, you will be prompted to give it a new name.

To move a program from one device to another, you can export it. From the File screen, select the Export button by the name of the project you wish to export. A number of options are available. You can use AirDrop to transfer the project to a neighboring device, you can email the project as an attachment, or your can upload to project to a cloud storage option such as Google Drive. The last option requires that you have an additional app installed for the cloud storage option that you choose. For example, you will need the Google Drive app to export your file to Google Drive. Because most storage apps are not available for the Amazon Fire, email or DropBox are the best choices for exporting with these devices.

To import a program from your email, tap it and then select Copy to BirdBlox. You may need to scroll to the right to see this option. Your device will open BirdBlox, but it will not load the file automatically. You will need to load the file from the File screen.

To load a file from iCloud Drive, Google Drive, or another cloud storage option, tap the cloud icon on the File screen. Use the Locations button to select the location you want. Then tap the name of the file that you want to open. The file will be imported into BirdBlox and saved locally. If you want to save your updates in the cloud, you will need to export the updated file again.

Using the Hummingbird Outputs

First, you will learn to use the lights, which are also called LEDs. The Hummingbird kit contains two types of LEDs, single color LEDs and tri-color LEDs. Single color LEDs have two wires, while tri-color LEDs have four wires.

Module 1: Single Color LEDs

A single color LED can be connected to one of four ports labeled “LEDS” on the Hummingbird board. Since you have four ports, you can connect up to four single color LEDs. The black LED wire should be connected to the ‘-’ terminal, while the colored wire should be connected to the ‘+’ terminal.

The Duo LED block is used to control a single color LED. This block requires two numbers. The number on the left is the number of the Hummingbird port to which the LED is attached. This will be a number between 1 and 4 that you can select from a drop-down menu. In the picture above, the LED is connected to LED port 1. The second number in the Duo LED block is the intensity of the LED. This is a number between 0 and 100. 0 means that the LED is off, and 100 means that the LED is at maximum brightness.

Attach a single color LED to LED port 1. Then drag the block shown below out into the Scripts area. Tap the 0. A menu will pop-up to allow you to enter another number. Change this number to 50 and then tap the check mark.This is your first program! Tap this block to run your program. The LED should turn on.

Exercise 1.1

Change the 50 to 0 and tap the block again. This should make the LED turn off. Change the 0 to 100 and tap the block. This is the maximum brightness of the LED. Try out other numbers between 0 and 100 to explore the different levels of brightness that are possible.

Building Tip

LEDs are quite small, but you can use a styrofoam ball to diffuse the light. This will make the light appear larger.

Events

So far, you have been running your program by tapping it. You can also use an event to start a program. An event is an action that the computer can recognize. Tap the Control menu.

The first block on this menu is when flag tapped. Drag this block into your program until it connects to the top of your script. Notice that the shape of this block shows you that it must be at the top of a script. It can’t be connected below another block.

Now you can run your program by tapping the green flag in the upper-right corner of the screen. Try using the flag to turn on the LED.

Creating Longer Scripts

The wait block can also be found on Control menu. This blocks pauses the program for the number of seconds shown in the block. This number can be a whole number or a decimal number.

You can use the wait block to turn the LED on for a certain period of time. For example, the program below will turn the LED on for three seconds, then turn it off.

Exercise 1.2

Connect a second LED to LED port 2. Write a script that turns the first LED on and then waits 2 seconds. Then the script should turn the second LED on for 2 seconds. Then the program should turn both LEDs off. Remember to save your work!

Programming Tip

When Scratch reaches an Duo LED block, it sets the LED and moves immediately to the next block. This means that if you do not have a wait block between two commands for the same LED, you may not see the effects of the first block. For example, you will only see the LED turn on very briefly when you run the script below. Place a wait block between the Huo LED blocks in order to see the LED turn on for a period of time and then turn off.

Exercise 1.3

Write a program that turns two LEDs on at different intensities, waits five seconds, and then turns both LEDs off.

Programming Tip

LEDs do not automatically turn off at the end of a program; you must add a block to turn each LED off. You can also turn them off by tapping the stop sign in the upper right corner of the screen.

Module 2: Tri-Color LEDs

A tri-color LED can be attached to one of the two ports labeled “TRI-COLOR” on the Hummingbird board. The four wires of the tri-color LED are red, green, blue, and black. The black wire should be connected to the ‘-’ terminal. The red wire should be connected to the ‘R’ terminal, the green to the ‘G’ terminal, and the blue to the ‘B’ terminal.

The tri-color LED actually has three tiny lights inside it. One is red, one is green, and one is blue. This is important for programming the tri-color LED. The Duo Tri-LED block is used to control a tri-color LED. This block requires four numbers. The number on the left is the number of the port to which the tri-color LED is attached (1 or 2). The other numbers are labelled RG, and BR controls the amount of red light from 0 (none) to 100 (maximum brightness). G and B control the amount of green and blue light, respectively, from 0 to 100. As an example, the block below makes a tri-color LED in port 1 turn green.

Exercise 2.1

What do you think the script below will do? Make a prediction and then try it out. How do you turn the tri-color LED off?

Exercise 2.2

Write a script to turn the tri-color LED five different colors.

Loops

Think about how you might turn an LED on and off repeatedly. One way to do this would be to use a long sequence of commands, but it is much simpler to use the repeat forever block in the Control menu. This block is called a loop. A loop is a programming structure that repeats a portion of a program. Look at the Control menu. Which of the other blocks do you think might be loops?

Other blocks can be placed inside the repeat forever block. The repeat forever block repeats the blocks inside it until you press the stop sign to stop the program. The loop shown below blinks the tri-color LED from green to blue. The loop repeats the four blocks inside it over and over. After the second wait block, the program immediately goes back to the first block inside the loop, the block that turns the LED green. What happens if you remove the second wait block?

The repeat block is a loop that repeats the blocks inside it a certain number of times. For example, the program below makes the tri-color LED change from green to blue ten times.

After the loop shown above ends, the light just stays blue. If you want to turn the LED off at the end of the script, you need to add a command below the repeat block.

Exercise 2.3

Make a tri-color LED blink on and off in your favorite color at least ten times in five seconds. The tri-color LED should blink evenly – in other words, it should be off for the same amount of time that it is on. Next, add a single color LED. The single color LED should be off when the tri-color is on and on when the tri-color is off.

Module 3: Motors

The Hummingbird kit works with three different kinds of motors: vibration motors, servo motors, and gear motors.

Vibration Motors

A vibration motor can be attached to one of the two ports labeled “VIBRATION” on the Hummingbird board. It does not matter which wire is attached to ‘+’ and which is attached to ‘-.’

The Duo Vibration block is used to control the vibration motor. This block requires two numbers. The number on the left is the port attached to the vibration motor (1 or 2) and the second number is the speed of vibration from 0 to 100. 0 means no vibration, and 100 means maximum vibration.

As an example, this script turns the vibration motor on for five seconds and then turns it off.

Exercise 3.1

Write a program that turns both a vibration motor and a single color LED on for four seconds and then off for four seconds. Then place these commands within a loop to repeat them five times.

Building Tip

Small, very light items such as googly eyes can be attached to a vibration motor so that they move when the motor vibrates.

Servo Motors

A servo motor is a motor that moves to a particular angle. The Hummingbird servo motor can rotate to any angle from 0° to 180°.

The servo motor has a small plug. This plug should be connected to one of the four sets of pins in the “SERVOS” section of the Hummingbird board. Each set of three pins is one servo port. The black wire should be connected to the ‘-’ pin, the red wire to the ‘+,’ and the yellow wire to the ‘S.’

Use hot glue to attach a popsicle stick to the white plastic circle on the servo motor. This will help you to see the movement of the servo motor more easily. If you don’t want to use hot glue, you can tape a feather to the plastic circle.

The Duo Servo block is used to move the servo motor. It requires two numbers. The number on the left is the port attached to the servo (1-4) and the second number is the angle (0° to 180°). The command below should move a servo motor attached to port 1 to 0°.

If you write a script with more than one angle, make sure to put a wait block between the Duo Servo blocks. If you omit the wait block from the script below, the servo will not have time to move to 90° before the command to move to 30°.

Exercise 3.2

The script below is supposed to move the servo motor repeatedly to two different angles, but there is a problem. Try out this script, and figure out how to correct it.

Exercise 3.3

Write a script that repeatedly moves the servo to five different angles. Make the tri-color LED a different color at each angle.

Building Tip

Before you start building with a servo, always set it to 90°. This will make sure that the servo can move both left and right once it is attached to your robot.

Gear Motors

The gear motor can be attached to either of the ports labeled “MOTORS” on the Hummingbird board. It does not matter which wire is attached to ‘+’ and which is attached to ‘-.’ When using the gear motor, you must also use the AC power adapter (or a battery pack).

Important Note: Do not cut the zip ties off your motors. Without the zip tie, the wires may break off the motor.

The Duo Motor block is used to control the gear motor. This block requires two numbers. The number on the left is the port attached to the motor. The number on the right is the motor speed. This number can be any whole number from -100 to 100. As an example, the script below turns the motor on for two seconds and then off.

Exercise 3.4

Use a small screwdriver to attach a wheel to the motor so that you can see it move more easily (or just place it on the motor without using a screw). Try several speeds between 0 and 100. Describe how the speed affects the motor. Try several negative speeds. What does it mean for the speed to be negative?

Important Note: You may notice that your motor rotates clockwise for positive numbers, while your neighbor’s rotates counterclockwise for the same number. This just means that you and your neighbor chose ‘+’ and ‘-‘ differently when you plugged in your motors. Either way is fine!

Exercise 3.5

Write a program that rotates the motor first in one direction, then in the other. Next, use a loop to repeat these actions.

Module 4: Sound and Using All the Outputs

You may want to add sounds to your robot project. You can use the Sound menu to record sounds and write a script to play them.

To record a sound, tap the Record sounds button. You will see this screen. Tap Record when you are ready to begin.

While you are recording, you will see this screen. When you have finished recording, tap Stop.

Your recording will automatically be named using the date and time. To give it a more informative name, tap the pencil beside the recording name.

There are two blocks you can use to play a sound you have recorded: play recording and play recording until done. In each block, you can select the sound you want to play from the drop-down menu.

Exercise 4.1

Try out the two scripts shown below. What is the difference between the play recording block and the play recording until done block?

Exercise 4.2

Are you ready to use all the Hummingbird outputs? Write a program that includes the following:

  • At least three LEDs
  • At least two different kinds of motors
  • At least one loop
  • At least two sounds

Using the Hummingbird Inputs

The Hummingbird LEDs and motors are output devices. Scripts in BirdBlox send commands to these devices to make something happen. The Hummingbird sensors, on the other hand, are input devices. They send information to the BirdBlox program. The program can use this information to make a decision or control a light or a motor.

All of the sensors are attached to the Hummingbird in the same way. A sensor can be attached to any one of the four ports labeled “SENSORS.” Each sensor has a red wire, a black wire, and a yellow wire. The red wire should be connected to ‘+,’ the black to ‘-,’ and the yellow to ‘S.’

Module 5: Distance Sensor

The distance sensor measures the distance to the closest object. Attach a distance sensor to the Hummingbird. Drag the Duo Distance CM block into the Scripts area away from the other blocks. Make sure that the port number is set to the port attached to the distance sensor. Tap this block to see the current value of the sensor. Then hold something in front of the sensor and tap the block again. Is the value of the distance sensor different?

The Duo Distance CM block measures the distance to an object in centimeters. The value of the distance sensor is between about 8 cm and 100 cm. The sensor cannot detect objects very close to the sensor or very far from it. It works best in the range of 20 cm to 60 cm.

Displaying a Sensor Value

To see the value of the distance sensor change, it is helpful to display it on the screen. To do this, you can use the Display block; it is located on the Tablet menu.

Place the Duo Distance CM block inside the Display block and tap the Display block. You should see the value of the distance sensor along the bottom of the screen. You can use the drop-down menu in the Display block to choose where on the tablet screen to display the value.

We will place the Display block inside a forever loop to continually display the value of the sensor.

Exercise 5.1

Run the script above and watch the value of the distance sensor change as you move an object back and forth in front of the sensor.

Programming Tip

Do not delete this script. You will find it helpful as you continue to use the distance sensor! You may need to remove the white display box from the screen to see your scripts. To do this, stop your script and tap the white box.

Making a Decision

You can use the distance sensor to enable a robot to make a decision. The if else block in BirdBlox is a decision block. This block is found on the Control menu. What do you notice about it?

The if else block has spaces in the middle that can hold other blocks. In addition, the if else block contains a hexagonal space. This space requires a Boolean block. A Boolean block is a block that can be either true or false.

You can use the distance sensor to create a Boolean block using the two blocks shown below, which are found on the Operators menu. Notice that these blocks match the shape of the space in the if else block.

Create the Boolean block shown below. This block is true if the value of the distance sensor is greater than 30 cm, and false otherwise. The value that the Boolean block uses to make a decision is called the threshold. In this case, the threshold is 30 cm. Click on the green part of the block with an object in front of the sensor. Is the block false?

Place the Boolean block into the hexagonal space in the if else block. When a script reaches an if else block, it checks the value of the Boolean block inside it. If the value is true, then the script runs the blocks inside the top part of the if else block. If the value of the Boolean block is false, then the script runs the blocks in the bottom part of the if else.

As an example, consider the script below. When you tap the flag, it will check the distance sensor. If the distance to an object is greater than 30 cm, the tri-color LED will turn green. Otherwise, it will turn red. Try it out!

The script above makes a decision each time you tap the flag. You may also want to repeat this decision over and over. Then the light will turn red whenever something gets close to the sensor. To do this, place the if else block inside a forever loop.

Exercise 5.2

Write a program that blinks a red light and moves a servo motor when an object is close to the distance sensor. When nothing is near the distance sensor, the light should be off and the servo should not move.

Exercise 5.3

The Boolean block for the if else is checked each time the program repeats the decision. However, the Boolean block is not checked during the statements inside the top or the bottom of the if else block. Try out the script below. In this script, the motor should be on when something is close to the distance sensor. When you run this program, you will notice that the program does not respond quickly when you move an object toward or away from the distance sensor. How can you modify this program to make it respond more quickly to a change in the value of the distance sensor?

Module 6: Rotary Knob

The rotary knob is another sensor; this sensor measures how much you have turned the knob. You can use the Duo Knob block to find the value of this sensor. This value will be between 0 and 100. Always remember to make sure that the Duo Knob block is set to the port attached to the rotary knob.

Exercise 6.1

Attach the knob to the Hummingbird board. Write a script that continually displays the value of the Duo Knob block. Then turn the knob all the way to the left. What is the value of the Duo Knob block? What is the value of the Duo Knob block when the knob is turned all the way to the right?

Exercise 6.2

Write a program that turns on a single color LED when the knob is turned far enough to the left. When the knob is turned far enough to the right, the LED should be off. What will your threshold be for this program? Remember, the threshold is the value that the Boolean block uses to make a decision.

In the previous exercise, you used the rotary knob to decide whether the LED should be on or off. Instead, you could use the knob to determine the brightness of the LED. Because the Duo Knob block is a number between 0 and 100, you can place it inside the Duo LED block to set the intensity of the light. Try out the script below. The forever loop repeatedly changes the brightness of the LED to match the value of the knob.

Exercise 6.3

Use the knob to control a gear motor and the amount of red in a tri-color LED (the amount of green and blue can be whatever you want). These components should change at the same time.

The rotary knob is useful for controlling the LEDs because its range (0-100) is the same as the input range for these components. If you place the knob block inside the Duo Servo block, as shown below, the servo will only move from 0° to 100°.

You can make the servo move from 0° to 180° using an arithmetic block from the Operators menu. These blocks enable you to add, subtract, multiply, and divide numbers.

Exercise 6.4

Place the Duo Knob block inside a multiplication block, as shown below. What number should you use instead of 0 so that the knob moves the servo from 0° to 180°? When the value of the knob is 0, the servo should be at 0°. When the value of the knob is 100, the servo should be at 180°.

Exercise 6.5

What do you think the script below will do? Make a prediction before you try it out.

Programming Tip

Don’t forget to set the port in the sensor block to the port on the Hummingbird board that you are actually using! If the value of the sensor is not changing as expected, be sure to check that the sensor block is reading the correct port.

Module 7: Light Sensor and Putting It All Together

The light sensor measures the amount of light around it. This sensor is very similar to the other sensors that you have learned about. You can use the Duo Light block to find the value of this sensor. This value will be between 0 and 100. Always remember to make sure that the Duo Light block is set to the appropriate port.

Exercise 7.1

Attach the light sensor to the Hummingbird board. Use the Duo Light block to measure the amount of light in your room. Then measure the value of the light sensor when you cover it with your hand. The average of these two values is a good threshold for the light sensor.

Exercise 7.2

Write a script that turns on a vibration motor when the light sensor detects that it is dark. Otherwise, the vibration motor should be off.

You have now practiced using all the Hummingbird motors and lights, as well as three of the sensors. There are other sensors, including a temperature sensor and a sound sensor. These work very similarly to the sensors you have already used. The Duo Temperature C block tells you the temperature in Celsius, and the Duo Sound block tells you the amount of noise around the Hummingbird on a scale of 0-100.

The last two exercises below will give you some practice using multiple sensors. After you have completed these, you will be ready to create many exciting, unique Hummingbird robots!

Exercise 7.3

Write a program that uses the knob sensor to control the color of a tri-color LED. However, the LED should only be on when an object is less than 30 cm from the distance sensor. Otherwise, the LED should be off. 

Exercise 7.4

Write a program that sends the servo to four different angles based on the values of the distance and light sensors. All of the values are shown in the table below.

Distance Light Servo Angle
Greater than 20 cm Above the threshold
Greater than 20 cm Below the threshold 60°
Less than 20 cm Above the threshold 120°
Less than 20 cm Below the threshold 180°

Congratulations! You have completed Hummingbird BirdBlox training. Have fun making robots!

Back to Top