Program

Print Go To MakeCode

Hummingbird Bit: MakeCode Lessons

Getting Started
Using the Outputs
Using the Inputs

Setup

Steps 1 2 3 4 5 6
Steps 1 2 3 4 5 6 7
Steps 1 2 3 4 5 6 7
Steps 1 2 3 4 5 6
Steps 1 2 3 4 5 6 7
Steps 1 2 3 4 5 6 7
Steps 1 2 3 4 5 6 7 8
Steps 1 2 3 4 5 6 7 8 9 10
Steps 1 2 3 4 5 6 7 8 9 10
Steps 1 2 3 4 5 6 7 8 9 10
Steps 1 2 3 4 5 6 7 8 9 10
Steps 1 2 3 4 5 6 7
Steps 1 2 3 4 5 6 7 8 9 10
Steps 1 2 3 4 5 6 7 8 9 10
Steps 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Steps 1

Setup

Step 1

This module will cover how to create a MakeCode program for the Hummingbird Bit and how to download the program to the micro:bit.

Step 2

Insert a micro:bit into your Hummingbird Bit Controller (you might need to push a little harder than you think!). The Hummingbird also needs a source of power, so connect it to the battery pack or AC power adapter. Connect your micro:bit to the computer with the USB cord.

Step 3

Use this button to open the MakeCode Environment. These lessons show the Chrome browser. We recommend Chrome, but Makecode will work in most browsers. You can also go to makecode.microbit.org, click extensions, and search for the Hummingbird Bit extension.

Step 4

Minimize the micro:bit simulation (the image on the left) to make more room for your programs. This simulator does not work with the Hummingbird Bit.

Give your program a useful name. MakeCode will automatically save your project under this name.

Step 5

Set your browser to ask you where to download files. This will make it easier to load your programs to the micro:bit.

Step 6

To get a sense of what it is like to load a program onto the micro:bit, click the purple Download button. Select the micro:bit as the download location. By default, MakeCode will send a smiley face to your micro:bit LED screen.

Single Color LED

Step 1

This module will show you how to use a single color LED with the Hummingbird Bit. A single color LED is a small light with two wires. The colored wire shows the color of the LED. The Hummingbird kit comes with red, green, and yellow LEDs.

Step 2

Use the terminal tool to plug an LED into LEDS port 1 on the Bit. The colored wire should be connected to ‘+’ and the black to ‘-.’

Step 3

The Hummingbird LED block is used to control a single color LED. To use this block, set the port of the LED to 1, 2 or 3 (MakeCode defaults to port 1), and set the brightness of the LED from 0% to 100%.

Step 4

The forever loop runs the Hummingbird LED block over and over. Since it sets the brightness to 100% each time, the light stays on at full brightness.

Reflect: What do you think would happen if you set the LED to 50% instead of 100%?

Step 5

Add a pause block, a second Hummingbird LED block, and a second pause block to the forever loop. The pause block stops the program for a number of milliseconds.

Step 6

Each time through the loop, the program turns the LED on, pauses, turns the LED off, and pauses again. The forever loop repeats this process over and over.

Reflect: What do you think would happen if the second pause block was not there?

Step 7

Write a program that makes the LED blink faster.

Tri-Color LED

Step 1

This module will show you how to use a tri-color LED with the Hummingbird Bit. A tri-color LED is a small light with four wires. The tri-color LED actually has three tiny lights inside it. One is red, one is green, and one is blue. You can combine different amounts of red, green, and blue light to make different colors.

Step 2

Use the terminal tool to plug a tri-color LED into TRI-COLOR port 1 on the Bit. The red wire connects to ‘R,” the green to ‘G,’, the blue to ‘B,’ and the black to ‘-.’

Step 3

The Hummingbird Tri-LED block is used to control a tri-color LED. To use this block, set the port of the LED to 1 or 2 (MakeCode defaults to port 1), and the amount of red, green, and blue from 0% to 100%.

Step 4

The forever loop runs the Hummingbird Tri-LED block over and over. Since red is set to 100% each time and green and blue to 0%, the light is red.

Reflect: What do you think would happen if you set both red and blue to 100?

Step 5

Add a pause block, a second Hummingbird Tri-LED block, and a second pause block to the forever loop. The pause block stops the program for a number of milliseconds.

Step 6

Each time through the loop, the program turns the LED red, pauses, turns the LED blue, and pauses again. The forever loop repeats this process over and over.

Reflect: How can you use a tri-color LED in a robot?

Step 7

Write a program that changes the color of the LED from purple to teal to green.

LED Screen

Step 1

In this module, you will learn to display icons and patterns on the micro:bit screen.

Step 2

Use the micro:bit Display block to display a small picture on the screen of the micro:bit. This pattern will make a happy face.

Step 3

When the space bar is pressed, the micro:bit Display is set to the image you created. Since the display was never programmed to turn off, the image remains on the screen.

Reflect: How would you change this code to display a different image?

Step 4

Add a pause block, a second show icon block, and a second pause block to the forever loop. The pause block stops the program for a number of milliseconds.

Step 5

Each time through the loop, the program shows the first expression, pauses, shows the second expression and pauses again. The forever loop repeats this process over and over.

Reflect: How would you change the code to show 3 different expressions on the micro:bit?

Step 6

Use the show leds block to create a program that show your very own animation.

Position Servo

Step 1

In this module, you will learn to use the position servo. The position servo is a motor that moves to a particular angle. The Hummingbird position servo can move to any angle from 0° to 180°.

Note: Hummingbird Base Kit users have an FS90 Micro Servo that works the same as the servo in these modules.

Step 2

Plug in the position servo to SERVOS port 1 on the Bit. Make sure the black wire is aligned to ‘-,’ the red wire to ‘+,’ and the white wire to ‘S.’

Step 3

The Hummingbird Position Servo block is used to control the position servo. To use this block, set the port of the servo to 1, 2, 3 or 4 (MakeCode defaults to port 1) and the angle from 0° to 180°.

Step 4

The forever loop runs the Hummingbird Position Servo block over and over, setting it to 90° each time.

Reflect: Why do you think the position servo moves once, then stops at 90°? Would the servo move if it was already at 90° before you start the program?

Step 5

Add a pause block, a second Hummingbird Position Servo block, and a second pause block to the forever loop. The pause block stops the program for a number of milliseconds.

Step 6

Each time through the loop, the program moves the servo to 90°, pauses, moves the servo to 180°, and pauses again. The forever loop repeats this process over and over.

Reflect: How would the movement of the servo change if the pause blocks were set to 300 ms instead of 1000 ms?

Step 7

Write a program that makes the servo move to 3 different positions.

Rotation Servo

Step 1

In this module, you will learn to use the rotation servo. The rotation servo is a motor that can rotate at different speeds.

Step 2

Plug in the rotation servo to SERVOS port 1 on the Bit. Make sure the black wire is aligned to ‘-,’ the red wire to ‘+,’ and the white wire to ‘S.’

Step 3

The Hummingbird Rotation Servo block is used to control the rotation servo. To use this block, set the port of the servo to 1, 2, 3, or 4 (MakeCode defaults to port 1) and the speed from -100% to 100%.

Step 4

The forever loop runs the Hummingbird Rotation Servo block over and over, setting it to 100% each time.

Reflect: What would happen if you set the speed of the Hummingbird Rotation Servo to -100% instead?

Step 5

Add a pause block, a second Hummingbird Rotation Servo block, and a second pause block to the forever loop. The pause block stops the program for a number of milliseconds.

Step 6

Each time through the loop, the program turns the motor on, pauses, turns the motor off, and pauses again. The forever loop repeats this process over and over.

Reflect: What do you think would happen if you changed the speed in the second Hummingbird Rotation Servo block to 40 instead of 0?

Step 7

Write a program that makes the servo spin counterclockwise quickly for 1 second, then clockwise slowly for 3 seconds.

Buzzer

Step 1

This module will show you how to program the buzzer output on the Hummingbird Bit. The buzzer can be used to create different musical tones that come directly from the Hummingbird controller board. The range of the buzzer is Low C to High B, or 131 to 988 Hertz (Hz).

Step 2

Drag out 3 play tone Middle C for 1 beat blocks from the Music folder and snap them into the Forever loop. Use the drop down menu on each block to select different notes. The range of the buzzer is Low C to High B, or 131 to 988 Hz.

Tip: Your browser will preview the tones through your computer’s speakers. Once you download the code, the sound will come through the board.

Step 3

The notes you’ve programmed will play for 1 beat, one right after another. In music, the “beat” represents how long a note will play. We’ll learn to speed this up and slow this down next.

Reflect: How could you make the notes play for longer?

Step 4

To make the notes play faster or slower, use the set tempo to (bpm) block from the Music folder. Snap the set tempo to (bpm) block into the top of the forever loop.

The “tempo” is the speed of a song. It is measured in beats per minute (bpm). MakeCode defaults to 120 bpm. Change the tempo by clicking the white oval and use your keyboard to set a new tempo.

Step 5

Using a little bit of math, we can find that a song with 120 bpm has beats lasting half a second (120 bpm / 60 seconds in a minute = 2 beats in each second). Use the drop down menu to change the bpm and see how that affects the speed of the notes.

Reflect: What would you set the bpm to make a song where each beat = 1 second?

Step 6

Drag out 3 rest(ms) blocks from the Music folder. Place one rest(ms) block after each play tone blocks. These blocks will cause there to be a silence, called a “rest.” Use the drop down menu to adjust the length of each rest.

Step 7

The notes you’ve programmed will now play with silences or “rests” in between them. You can now program your Hummingbird to play any song at any tempo!

Step 8

Can you write a program to play a simple song you know?

Light Sensor

Step 1

This module will show you how to use a light sensor as an input with the Hummingbird Bit. A light sensor is a component that collects data based on how much light surrounds the sensor. The range of the light sensor is 0 to 100.

This module assumes that you have already completed the single color LED module.

Step 2

Plug a sensor into your board. Any Hummingbird sensor can be connected to any of the three ports labelled “SENSORS” on the Bit. The yellow wire connects to ‘S,’ the red to ‘+,’ and the black to ‘-.’

Step 3

To see the value of the sensor on the micro:bit LED screen, place the Hummingbird Sensor block inside a show number block.

The Hummingbird Sensor block is near the bottom of the Hummingbird folder in MakeCode. Use the drop-down menu to select “Light.”

Step 4

Interact with the light sensor and watch the number on the micro:bit LED screen change.

Reflect: How can you make the value of the sensor higher or lower?

Step 5

You can use the sensor data to control the brightness of an LED.

Plug an LED into LED port 1.

Step 6

Place a Hummingbird Sensor block inside a Hummingbird LED block.

Step 7

The Hummingbird Sensor block measures the value of the light sensor and sets the LED brightness to that value.

Reflect: In this program, the micro:bit runs the Hummingbird LED block about 40 times per second. What do you think would happen if you added a pause block to the forever loop?

Step 8

Your light sensor value can be used to make decisions. To turn on an LED when the value of the sensor is low, use an if else block from the Logic folder. This block requires a comparison block, which is also in the Logic folder.

Step 9

This program compares the value of the light sensor to 10. If the sensor value is less than 10, the program runs the block inside the if section of the if else, and the LED turns on. When the sensor value is greater than 10, the program runs the block inside the else section, turning the LED off.

Step 10

Can you make an LED turn on and off with a different sensor? Disconnect the sensor you’ve been using and connect a new sensor. Use the drop-down menu in the Hummingbird Sensor block to make the block match your new sensor.

Dial Sensor

Step 1

This module will show you how to use a dial sensor as an input with the Hummingbird Bit. A dial sensor is a component that collects data based on how much you rotate the knob. The range of the dial sensor is 0 to 100.

This module assumes that you have already completed the single color LED module.

Step 2

Plug a sensor into your board. Any Hummingbird sensor can be connected to any of the three ports labelled “SENSORS” on the Bit. The yellow wire connects to ‘S,’ the red to ‘+,’ and the black to ‘-.’

Step 3

To see the value of the sensor on the micro:bit LED screen, place the Hummingbird Sensor block inside a show number block.

The Hummingbird Sensor block is near the bottom of the Hummingbird folder in MakeCode. Use the drop-down menu to select “Dial.”

Step 4

Interact with the dial sensor and watch the number on the micro:bit LED screen change.

Reflect: How can you make the value of the sensor higher or lower?

Step 5

You can use the sensor data to control the brightness of an LED.

Plug an LED into LED port 1.

Step 6

Place a Hummingbird Sensor block inside a Hummingbird LED block.

Step 7

The Hummingbird Sensor block measures the value of the light sensor and sets the LED brightness to that value.

Reflect: In this program, the micro:bit runs the Hummingbird LED block about 40 times per second. What do you think would happen if you added a pause block to the forever loop?

Step 8

Your dial sensor value can be used to make decisions. To turn on an LED when the value of the sensor is high, use an if else block from the Logic folder. This block requires a comparison block, which is also in the Logic folder.

Step 9

This program compares the value of the dial sensor to 50. If the sensor value is greater than 50, the program runs the block inside the if section of the if else, and the LED turns on. When the sensor value is less than 50, the program runs the block inside the else section, turning the LED off.

Step 10

Can you make an LED turn on and off with a different sensor? Disconnect the sensor you’ve been using and connect a new sensor. Use the drop-down menu in the Hummingbird Sensor block to make the block match your new sensor.

Distance Sensor

Step 1

This module will show you how to use a distance sensor as an input with the Hummingbird Bit. A distance sensor is a component that collects data based on how close or far you are to the sensor. The range of the distance sensor is 1 to 260 cm.

The distance sensor is not included in the Hummingbird Bit Base Kit.

This module assumes that you have already completed the single color LED module.

Step 2

Plug a sensor into your board. Any Hummingbird sensor can be connected to any of the three ports labelled “SENSORS” on the Bit. The yellow wire connects to ‘S,’ the red to ‘+,’ and the black to ‘-.’

Step 3

To see the value of the sensor on the micro:bit LED screen, place the Hummingbird Sensor block inside a show number block.

The Hummingbird Sensor block is near the bottom of the Hummingbird folder in MakeCode. Use the drop-down menu to select “Distance.”

Step 4

Interact with the distance sensor and watch the number on the micro:bit LED screen change.

Reflect: How can you make the value of the sensor higher or lower?

Step 5

You can use the sensor data to control the brightness of an LED.

Plug an LED into LED port 1.

Step 6

Place a Hummingbird Sensor block inside a Hummingbird LED block.

Step 7

The Hummingbird Sensor block measures the value of the light sensor and sets the LED brightness to that value.

Reflect: In this program, the micro:bit runs the Hummingbird LED block about 40 times per second. What do you think would happen if you added a pause block to the forever loop?

Step 8

Your distance sensor value can be used to make decisions. To turn on an LED when the value of the sensor is low, use an if else block from the Logic folder. This block requires a comparison block, which is also in the Logic folder.

Step 9

This program compares the value of the distance sensor to 15. If the sensor value is less than 15, the program runs the block inside the if section of the if else, and the LED turns on. When the sensor value is greater than 15, the program runs the block inside the else section, turning the LED off.

Step 10

Can you make an LED turn on and off with a different sensor? Disconnect the sensor you’ve been using and connect a new sensor. Use the drop-down menu in the Hummingbird Sensor block to make the block match your new sensor.

Sound Sensor

Step 1

This module will show you how to use a sound sensor as an input with the Hummingbird Bit. A sound sensor is a component that collects data based on how much sound surrounds the sensor. The range of the sound sensor is 0 to 100.

The sound sensor is not included in the Hummingbird Bit Base Kit.

This module assumes that you have already completed the single color LED module.

Step 2

Plug a sensor into your board. Any Hummingbird sensor can be connected to any of the three ports labelled “SENSORS” on the Bit. The yellow wire connects to ‘S,’ the red to ‘+,’ and the black to ‘-.’

Step 3

To see the value of the sensor on the micro:bit LED screen, place the Hummingbird Sensor block inside a show number block.

The Hummingbird Sensor block is near the bottom of the Hummingbird folder
in MakeCode. Use the drop-down menu to select “Sound.”

Step 4

Interact with the sound sensor and watch the number on the micro:bit LED screen change.

Reflect: How can you make the value of the sensor higher or lower?

Step 5

You can use the sensor data to control the brightness of an LED.

Plug an LED into LED port 1.

Step 6

Place a Hummingbird Sensor block inside a Hummingbird LED block.

Step 7

The Hummingbird Sensor block measures the value of the light sensor and sets the LED brightness to that value.

Reflect: In this program, the micro:bit runs the Hummingbird LED block about 40 times per second. What do you think would happen if you added a pause block to the forever loop?

Step 8

Your sound sensor value can be used to make decisions. To turn on an LED when the value of the sensor is high, use an if else block from the Logic folder. This block requires a comparison block, which is also in the Logic folder.

Step 9

This program compares the value of the sound sensor to 70. If the sensor value is greater than 70, the program runs the block inside the if section of the if else, and the LED turns on. When the sensor value is less than 70, the program runs the block inside the else section, turning the LED off.

Step 10

Can you make an LED turn on and off with a different sensor? Disconnect the sensor you’ve been using and connect a new sensor. Use the drop-down menu in the Hummingbird Sensor block to make the block match your new sensor.

Buttons

Step 1

This module will show you how to program the A and B buttons on the micro:bit to control the single color LED output of the Hummingbird Bit. The micro:bit’s A and B buttons can be used as inputs. Pressing them can be an “event” to trigger other actions.

This module assumes that you have already completed the single color LED module.

Step 2

Plug in a single color LED. The A and B buttons are located on the face of the micro:bit. They can be pressed one at a time or together.

Step 3

Remove the forever loop from your screen. Drag out the on button A pressed block from the Input folder. Drag a Hummingbird LED block from the Hummingbird into the loop. Set the Hummingbird LED to 100%. Download the code.

Step 4

The A button being pressed causes the Hummingbird LED to turn on.

Reflect: How could you use the A button to turn a tri-color LED red?

Step 5

Drag out another on button A pressed block from the Input folder. Use the drop down menu to change the second code to on button B pressed. Program the Hummingbird LED to turn off when the B button is pressed.

Step 6

The A and B buttons now turn the LED on and off respectively.

Step 7

Can you use on button A+B pressed block to make the LED blink 4 times?

Accelerometer

Step 1

This module will show you how to use the accelerometer as an input to control a Hummingbird tri-color LED. The range of the x, y, and z variables on the accelerometer is -1024 to 1024 mg.

This module assumes that you have already completed the tri-color LED module.

Step 2

Plug in the tri-color LED. You do not need to attach the accelerometer. The accelerometer is built into the micro:bit.

Step 3

Remove the forever loop from your screen. Drag out the on shake block from the Input folder. Drag out 2 Hummingbird Tri-LED blocks from the Hummingbird folder and 1 pause (ms) block from the Basic folder. Write a program to turn the tri-color LED on and off inside of the on shake block.

Step 4

When you shake the Hummingbird controller board, your tri-color LED will turn red for 1 second and then turn off.

Reflect: How could you make the tri-color LED blink red and blue 3 times when the micro:bit is shaken, then turn off? (Hint: Look in the Loops folder!)

Step 5

You can also tilt your Hummingbird Bit in different directions to change the colors of the tri-color LED.

First, delete the pause and second Hummingbird Tri-LED blocks. Select the drop down menu in the on shake block, and change it to read “logo up.” Duplicate this whole event. Then, use the drop down menu to select “logo down” in the second on shake block. Change the tri-color LED to green on the second Hummingbird Tri-LED block.

Step 6

When you tilt the Hummingbird Bit controller forward and back, the tri-color LED will change color from red to green.

Reflect: How could you make this code control a position servo to go from 0 to 180 degrees?

Step 7

Write a program that makes the tri-color LED turn blue and purple when the Hummingbird Bit is tilted left and right.

Step 8

While we’ve been using the accelerometer as an event up to this point, you can also use the accelerometer’s value to slowly alter a component by nesting it, which you can also do with sensors. This action requires us to use some math.

First, delete your 2 on logo up and on logo down event blocks. Drag out a forever loop from the Basic folder. Drag a Hummingbird Tri-LED block into the forever loop. Drag a division block from the Math folder. Nest this block into the white oval next to “Red” in the Hummingbird Tri-LED block.

Nest an acceleration (mg) x block from the Basic folder into the first space in the division block. This accelerometer can measure front to back movement (called x), side to side movement (called y), and up and down movement (called z). Use your keyboard to type the number 10 into the second space of the division block.

Step 9

Why do you need a math block here? The range of the x, y, and z values on the accelerometer is -1024 to 1024 mg. In order for this sensor to effectively control the tri-color LED, which has a range of 0-100, we need to divide the value of the accelerometer block by about 10.

Reflect: How could you make the y variable of the accelerometer control the brightness of the blue of the tri-color LED at the same time?

Step 10

Write a program that:
– Makes the x variable of the accelerometer control the brightness of the red of the tri-color LED.
– Makes the y variable of the accelerometer control the brightness of the blue of the tri-color LED.
– Makes the z variable of the accelerometer control the brightness of the green of the tri-color LED.

Compass

Step 1

This module will show you how to use the compass as an input to control the movement of a Hummingbird position servo. The range of the compass is 0° to 359°.

This module assumes that you have already completed the position servo module.

Step 2

Drag the show number block from the Basic folder into a forever loop. Drag the compass heading block from the Input folder into the show number block.

Step 3

The compass needs to be calibrated before it can be used. Follow the steps displayed on the micro:bit’s LED array to calibrate the compass. The micro:bit asks you to “TILT TO FILL SCREEN.” Tilt the micro:bit so that all the LEDs on the LED display screen are lit. This step will need to be repeated each time you download.

Step 4

The micro:bit’s LED screen is now displaying the input value from the compass. The compass measures its heading in degrees, from 0-360. North is 0.

Reflect: What number represents South?

Step 5

Plug in the position servo. You do not need to attach the compass. The compass is built into the micro:bit.

Step 6

Drag the compass heading block out of the show number block and delete the show number block. Drag out a Hummingbird Position Servo block from the Hummingbird folder and nest the compass heading block inside of it.

Step 7

The position servo will now rotate to match the compass heading. Although the range of the compass is 0°-359°, the position servo will stop at 180 degrees, because the range of the position servo is 0°-180°.

Reflect: How could you use the compass to control the brightness of a single color LED?

Step 8

The compass value can also be used to make decisions. We will now set your position servo to either 0 or 180 degrees based on the compass value.

First, drag the compass heading and Hummingbird Position Servo blocks apart and outside of the forever loop. Drag an if else block from the Logic folder into the forever loop. Nest a less than block from the Logic folder into the hexagon space of the if else block.

Nest the compass heading block into the first space of the less than block, and type “180” degrees into the second space. Drag the Hummingbird Position Servo block into the first open space of the if else block and set it to “0.” Drag another Hummingbird Position Servo block into the second open space of the if else block and set it to “180.”

Step 9

This program compares the value of the compass to 180. If the compass value is less than 180 (indicating west), the position servo is set to 0 degrees. When the compass value is greater than 180 (indicating east), the position servo is set to 180 degrees.

Reflect: How could you use a similar code to turn a tri-color LED red and blue based on the value of the compass?

Step 10

What kind of robot could you build that would respond to data from the compass?

Radio

Step 1

This module will show you how to use the radio feature to transmit data from one Hummingbird controller to another, “controlling” one device with another. For this module, you will need 2 Hummingbird Bit boards*, 1 tri-color LED, and 1 dial sensor.

This module assumes that you have already completed the tri-color LED, buttons, and sensor modules.

*In steps 2-8, you will be using a micro:bit by itself without a Hummingbird controller board. To power this micro:bit, you can either use a AAA battery pack or the USB cord included in your kit.

Step 2

We will begin by programming the “transmitting” Hummingbird (which we will call HB1) to send a message when the A button is pressed. Eventually, pressing the A button on HB1 will turn the tri-color LED on HB2 red.

On HB1:
First, remove the forever loop from your screen. Next, set the radio group by dragging out the radio set group block from the Radio folder into the On Start loop. Set the radio group to a number between 1-255. Drag out the on button A pressed block from the Input folder. Drag the radio send string block from the Radio folder into the on button A pressed loop. Give the string a message like “red.” (Capitalization will matter, so carefully note the exact string you are sending).

Step 3

Switching to the second Hummingbird board, plug in the tri-color LED into port 1.

Step 4

We will now program the “receiving” Hummingbird (HB2) to use a received message to turn the HB2 tri-color LED red.

On HB2:
First, remove the forever loop from your screen. Next, drag out the radio set group block from the Radio folder into the on start loop. Set the radio group to the same number as your HB1. Drag out the on radio received – receivedString block from the Radio folder. Drag a Hummingbird Tri-LED block from the Hummingbird folder into the on radio received – receivedString block. Set Red to 100%.

Step 5

When the A button is pressed on HB1, the tri-color LED on HB2 turns red.

Reflect: Could you write a similar script to make a message or picture appear on the LED screen of HB2 when you press the A button on HB1?

Step 6

Now we want to program our linked Hummingbirds so that pressing the A and B buttons on HB1 will turn the tri-color LED on HB2 red and blue.

First, duplicate the on button A pressed loop and set it to on button B pressed. Give this string a different message like “blue.” (Capitalization will matter, so make note of the string you are sending).

Step 7

We now need a way for HB2 to differentiate between strings. Based on the string it receives, HB2 will either turn the tri-color LED red or blue.

On HB2:
First, remove the Hummingbird Tri-LED block from the on radio received loop and set it to the side. Drag an if then statement from the Logic folder into the on radio received block. Nest a 0 = 0 block from the Logic folder into the hexagon space of the logic blocks. Nest the receivedString block from the Variables folder into the first space in the 0 = 0 block.

Click “Advanced” on the bottom of the folders section to reveal the Text folder. Nest a ” _ “ block into the second space of the 0 = 0 block. Type “red” into that space, exactly matching the string HB1 sent. Drag a Hummingbird Tri-LED block from the Hummingbird folder into the on radio received – receivedString block. Set Red to 100%. Duplicate the if then block and set the text to “blue” and the tri-color LED to 100% blue.

Step 8

When the A button is pressed on HB1, the tri-color LED on HB2 turns red. When B button is pressed on HB1, the tri-color LED on HB2 turns blue.

Reflect: How could you do something similar with a position servo, setting it to either 0 or 180 degrees based on which button is pressed?

Step 9

Next, plug the first micro:bit into a Hummingbird. Then plug a dial sensor into sensor port 1.

Step 10

Now we’re going to program a dial sensor on HB1 to control the tri-color LED on HB2.

On HB1:
First, drag the radio send string “red” and radio send string “blue” blocks to the side and save them for later. Delete the on button A pressed and on button B pressed blocks. Drag out a forever loop from the Basic folder. Drag an if then else statement from the Logic folder into the forever loop.

Nest a less than block from the Logic folder into the hexagon space of the if then else block. Drag the Hummingbird Light block from the Hummingbird folder into the first space of the less than block. Use the drop down menu to select “Dial.” Type “50” into the second space of the less than block. Drag the radio send string “red” block into the first space, and the radio send string “blue” block into the second space of the if then else statement.

Step 11

We actually don’t need to change anything in our code for HB2! It will still be receiving the same strings, “red” or “blue,” but now the dial sensor will be triggering different strings instead of the A and B buttons.

Now, when you turn the HB1 dial sensor above 50%, the HB2 tri-color LED turns blue. When you turn the HB1 dial sensor less than 50%, the HB2 tri-color LED turns red.

Reflect: Could you recreate this same function with a different sensor?

Step 12

Up to this point, we have been sending strings of text as messages. Now we will be sending number values as messages between HB1 and HB2. We will use the dial sensor on HB1 to control the brightness of the tri-color LED on HB2 in real time.

On HB1:
First, delete everything inside the forever loop. Drag out a radio send number block from the Radio folder. Nest the Hummingbird Dial sensor block into the radio send number block.

Step 13

We need to reset the HB2 to look for its radio signal in numbers rather than strings of text.

On HB2:
Delete the on radio received – receivedString loop. Drag out an on radio received – receivedNumber block from the Radio folder. Drag out a Hummingbird Tri-LED block into the on radio received – receivedNumber loop. Nest a red receivedNumber block from the Variables folder into the tri-color LED red space.

Step 14

As you turn the dial sensor on HB1, the brightness of the tri-color LED on HB2 will increase and decrease in real time.

Reflect: How could you make the dial sensor also control the brightness of the blue light in the tri-color LED?

Step 15

Combining skills and components like accelerometer, compass, and motors can make for some great animatronic and puppeteering projects. What sort of animatronic puppet could you make, controlled by radio?

Moving and Turning

Forward/Back Block

Block: Forward/Back

This landing is gonna get pretty interesting. Define “interesting”. Oh God, oh God, we’re all going to die? Gave up a brilliant future in medicine as well. It’s madness. Madness? Have you looked at this scan carefully, Doctor? At his face? It’s love, in point of fact. Something a good deal more dangerous. Dear Buddha, please bring me a pony and a plastic rocket… You’re fighting a war you’ve already lost. Yeah, well, I’m known for that. How come they ain’t blowin’ us out the air? They wanna run us down. The up-close kill. They want us alive when they eat us. She is startin’ to damage my calm.

Challenge

Love. You can learn all the math in the ‘verse… but you take a boat in the air that you don’t love… she’ll shake you off just as sure as the turn of the worlds. Love keeps her in the air when she ought to fall down… tells you she’s hurting before she keels. Makes her a home.