Lesson 3 – micro:bit Display

Hummingbird Components

None

Java Concepts

Strings

Teacher Materials

Get Access

In the last two lessons, you have learned to use the LEDs in your Hummingbird kit. There are also LEDs on the micro:bit. These 25 tiny LEDs are arranged in a 5 by 5 grid. In this lesson, you will write programs that use these LEDs to make letters and pictures.

To write letters and numbers on the micro:bit, use the print() method. This method takes a string parameter, which is text within quotation marks. The string must have 15 or fewer characters and should contain only digits and English letters (upper or lower case).

The print() method displays the string on the micro:bit LED array one letter at a time. For example, the code below shows the letter ‘H’ then the letter ‘i’ on the micro:bit.

Exercise 1

Print your name on the micro:bit. Make sure that the program pauses long enough to display all the letters before the program ends.

To turn individuals micro:bit LEDs on or off, use the setPoint() method. This method takes three parameters. The position of the LED is given by the row and column parameters, which should both be between 1 and 5. The third parameter is the value of the LED, which must be 0 (off) or 1 (on).

Exercise 2

Try out this code. It should turn on the LEDs at the four corners. Then modify this code to turn the four corners on and then off.

Exercise 3

Draw a smiley face on the micro:bit LED display.

Exercise 4

What do you think this code will do? Make a hypothesis, and then test it out.

Exercise 5

Modify the code from Exercise 5 to turn a horizontal line of LEDs on and then off.

Extra Challenge

What do you think this code will do? Make a hypothesis, and then test it out. Then write your own program that uses one for loop inside another; this is called nesting.

Back to Top