Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

Course 2 – Exploring the micro:bit

This lesson introduces teachers to a basic quick-start in setting up a micro:bit chipset.

• Computer-science
• Scratch
• micro:bit

Print lesson

• 65+ mins
• micro:bit

Resources (2)

• Teacher quick start guide


Teachers should read this before starting

• Explore the many features of the micro:bit!


Teachers should read this before starting

Before You Start


If your only experience with ‘computer programming’ is in setting up your smart phone,
getting hooked up on Uber, then Friending on Facebook, you’ll need have no concern.
There is no homework, and there are no e-drills. You’ll have manipulables to play with,
coding is graphical-interfaced, most of all it’s fun! We encourage you to approach these
lessons with ‘childlike eyes’, and learn that way. Build, then trash! Do crazy stuff! Make
all kinds of stoopid, just like your students will when you present their lesson plans. Our
goal is To Do. To engage their minds. To embark upon this new age of discovery. We
have rich resource libraries, and a range of ready-written lesson plans for you to try.
Introduction
This second lesson introduces a basic understanding of the BBC micro:bit chipset that
we will use as a controller in block programming our Scratch3 implementation, on either
Chromebook or an iPad. In our first lesson, we learned Scratch3 programming is via a
graphical interface, combining ‘clickable’ visual block tiles of Scratch code that, once
assembled, perform some program function. Scratch3 has the control capability to use a
mouse, space bar and arrow keys, -or- a micro:bit can be used as the controller.

What makes Scratch3 for micro:bit exciting for the classroom is its ability to interface the
block programming with the micro:bit chip set controller, either through a USB dongle,
or using its battery-powered bluetooth remote interface. The micro:bit chipset contains
several useful integrated functions that perform on Scratch3’s interface. There are two
push-buttons, a 5x5 LED light display, and built-in compass, tilt and accelerometer
functions. This allows your students to control the Scratch3 display with the chipset in
their hands, just like a game controller, one that they build and integrate themselves.

Let’s take an example. The Foot-Hop game. Students love competing, as long as the
game is simple and easy. If you cross your legs, then hop your free foot up and down,
you quickly find your leg muscle tiring. It’s a big muscle! Using a micro:bit’s gyroscopic
features and its bluetooth, then tying a programmed micro:bit to their shoe laces, the
Scratch3 interface will count how many times students were able to hop their foot (or
hand) in say, a minute. Wait, that’s not all! We can assemble more complete block
coding, using the visual program tiles and its graphical sprites, backdrops and sounds
library, to create a rich sensory control environment. Each time a student’s foot or hand
hops, their personal sprite on the Scratch 3 screen can leap in the air, as it shouts out
the number of hops. Each micro:bit also has a built-in voice module and flashing LED
display that could buzz out ‘Breanna hopped 75 times!’ then flash a scrolling 75!

Background
Teachers are highly encouraged to first complete the following:

• Teacher Quick Start Guide (see Resources above)


• Explore the many features of the micro:bit!

Teacher Guide
Learning Objectives
1. Unpacking the micro:bit kit and powering it up to check its operation.
2. Building simple code sequences in Microsoft Block Editor to confirm functions.
3. Develop agility in applying different onboard functions to affect code processes.
4. Apply the above knowledge to develop a ‘how-to’ ‘Quick Start’ guide that uses
these features as an integral part of your classroom lesson planning.

Agenda
• Background
• Setup Activity (20 mins)
• Coding Challenge Guided Practice (20 mins)
• Independent Practice – Scripting Student Lessons (15 mins)
• Present Independent Practice - Teachers Present Projects (5 mins per group)
• Quiz (10 mins)

Coding challenges assessment


4 = All four challenges were accomplished
3 = Three challenges were accomplished
2 = Two challenges were accomplished
1 = One challenge was accomplished OR
challenges were tried but unsuccessful

Independent practice assessment


4 = Uses all functions, creates an engaging hex file, and micro:bit works
3 = Uses 2 functions with a multi-function hex file, and micro:bit works
2 = Uses 1 function with a single-function hex file, and micro:bit works
1 = Micro:bit operates, and there was an attempt to create a hex file

Tips on setting up a micro:bit


It is simpler to set up and test (explore) the micro;bit functions using the MS Block Editor
programming tools. If you tried Course 1 on using the Scratch3 graphical interface, then
you might wonder why we don’t just use Scratch 3? The Scratch 3 interface is an online
teaching stage for animations. Those programming tools are designed to create sprite
actions on some backdrop. In Scratch 3, the micro:bit is an optional hardware controller.

The function of MS Block Editor is solely to program the micro:bit, not animate a stage.
It uses a similar block coding method that you should already be comfortable with, after
Course 1. There is a very useful graphic emulator on the MS Block Editor display, that
shows you what your real micro:bit should be doing. Think of MS Block Editor as taking
your car to a tune-up mechanic, before going for a spin through Scratch 3 Land. After
we get your micro:bit all turned up in MS Block Editor, then we will introduce the Scratch
3 link interface, where you’ll learn a facility in programming your micro:bit for stage.

WARNING: In temperate climate dry winters with inadequate A/C humidity


control, it’s very easy to build up a damaging static charge between students
when handing a micro:bit chipset back and forth. Talk with the school utilities
technician, and make sure that your classroom R/H is above 55% when you
schedule your period of micro:bit- with-Scratch 3 exploration. You can also
ask students to take their shoes off in dry-day periods. Make it a part of the
Foot-Hop experiment and they’ll probably do it without complaint. Also hand
cleanliness if very important when handling chipsets. Have students wash
their hands, especially after lunch. Potato chips and microchips don’t mix!!

Activity
What you'll need

• 1 - micro:bit (OEM original kit, new in static foil)


o 1 - USB cable (1 m dongle for micro:bit)
o 1 - AAA battery pack (with jack for micro:bit)
• 2 - AAA batteries (IMPORTANT: avoid cheap off-brands)
• Computer with USB port and Internet (for setting up in MS Block Editor)

micro:bit Features
Open http://microbit.org/ and scroll down a half page to ‘I’m a teacher’ and ‘I’ve got my
micro:bit’. BBC micro:bit teachers are in UK, not USA, and the website no longer requires
the teacher registration anyway. We’ll use the right panel ‘Get Started’ under ‘I’ve got my
micro:bit’. Go ahead, click on it. Hello! Then click on Features, if you haven’t done so
already. We’re looking at the ‘front’ of the chipset at left, and ‘rear’ of the chipset at right:
[IMAGE] front and rear of micro:bit

The ‘front’ at left has Button ‘A’, then in center, a 5x5 LED display, with upper left as (0,0)
and lower right as (4,4) when addressing which LED to light. At right is Button ‘B’. Along the
bottom are three addressable input/output ‘pins’, 0, 1, 2, then a 3V power ‘pin’ and a ground.
The ‘rear’ at upper left has a bluetooth antenna, then a USB dongle connector at top center,
a reset button, and a 3V power receptacle at top right. Stencils identify each of the chips.
In software, using a voice emulator and connecting to an external speaker with pins 0 and 1,
the micro;bit can also perform machine voice imitations, like Steven Hawkins own emulator!

Q. How would you write this Features paragraph into an ‘explore’ presentation for students?

Documentation
Unwrapping
Micro:bits originate in UK and are sold through US resellers, as both kits and individual
chipsets. Preferably, because of the difficulty of finding compatible components, we suggest
you buy OEM kits like the one we’ll show. Remember, a Chinese chipset knockoff is now
competing with micro:bit, and resellers are re-kitting with used and returned components.
There are good after-market vendors like Kitronik UK and Elegoo CH for the higher level of
circuit-building and chipsets, but for right now, find a quality, known supplier of original OEM
kitted micro:bits, then you can follow along with this discussion.

Your bubble-wrap package contains a USB dongle (identify the trademark black-on-white),
safety guide and quick start flyer, a twin-AAA battery pack with correct-shape power jack
and an authentic micro:bit in static foil. If your kit doesn’t look like this, you’re not ready.
WARNING: As adults we learned how to unpack electronics. We know to unwrap
and lay out components, read instructions, combine components, and test
(explore) in sequence. Students will need scaffolding before opening day! We
know what an anti-static bag is on delicate electronics, and we know not to bend,
poke or twist the components. In this Course 2, more than any other, you’re
going to want to take written notes on how you’ve acquired this information. Think
how to distill that instruction set down to K-12, and record notes as we go. Once
you’re on the other side of this learning curve, it’s very difficult to de-construct it!

[IMAGE] Unwrapped kit, showing USB dongle, battery pack and micro:bit (in foil)

Assembling a micro:bit
Time yourself in this exercise so you have an idea of your prep before class, and setup time
at the top of the hour. Carefully open the foil pack and slide your micro;bit into your palm.
Get in the habit of holding it by the side edges, not by the top and bottom pins. Turn it over
and get familiar with both sides’ components. Break a battery pack open (our kit came with
batteries, your kits may not), then taking two new AAA batteries, correctly install them in the
battery holder. Look closely at the battery jack and the connector socket on the micro;bit.
The wires are slightly offset, and there’s a vertical fin that only fits one way, so only one
orientation (battery polarity) is possible. The jack fits very snugly into the socket (below):
[IMAGE] Top edge, showing USB port, reset button and 3V DC power socket:

Start up auto-testing
Go ahead, carefully plug in the battery pack (if you don’t have new batteries you can also
just plug the USB dongle into a spare computer port, then into the micro:bit USB socket).
After a moment the front LED display will light solid red 5x5, then start flashing faster, and
flickering faster, until it (shortly) stops with a single LED lit in the center ((2,2). Fadeout.

[IMAGE] micro:bit LEDs all lit and micro:bit LED (2,2) lit from auto-test

Be watching carefully! The micro:bit can’t self-diagnose its display. If all the LEDs are lit and
then smoothly flashing with no dead LEDs, the display is functioning correctly. The single
LED fades out, then HIEILILIO, will scroll across the screen, following by A I , the
prompt to test Button A (on the left). Push it. The LED display will fully light up then fade,
replaced by B I to test Button B on the right. Push it. Again the display will fully light and
fade, then will scroll out SIHIAIKIEI! The setup is asking you to test the onboard
gyroscope (compass, tilt, accelerometer). Shake the chipset gently in all directions. If all
LEDs (after a bit) light up 5x5, then the accelerometer function is working correctly. Next the
display will scroll CIHIAISIEITIHIEIDIOITI! , then show a flashing LED in
the (0,0) upper left position, with a fixed LED in the (2,2) center. This is a test of the tilt and
compass functions. Tilt and rotate the chipset, trying to ‘chase’ the two LEDs until they
merge together into one flashing LED. As soon as you achieve that, the display will scroll
GIRIEIAITINIOIWIGIEITICIOIDIIINIGI!
The LED display cycles through a number of flashing shapes, including a ♥. You’re done!
Your micro:bit has passed a startup auto-test, and is ready to code!

WARNING: The self-test we’ve described will only display with a new micro:bit
‘flashed’ at the factory. ‘Flashing’ is the process of downloading hex code onto
the chipset to run a self-test. If the micro:bit was used and returned before it was
resold to you, (or if you are going through a pile of used chipsets to make sure
they still work), the micro:bit may have been ‘flashed’ with a new code sequence,
including one that may display nothing. The micro:bit might be OK! We’ll create
our own test code to ‘flash’ onto the micro:bit, so you can quickly tell if a micro:bit
is defective, or was re-flashed with a new hex code that had no LED functions.

‘Kid-proofing’ micro:bit
At this point, as a teacher, you’re already thinking about those 30 micro:bits and 30
battery packs with those 60 fragile battery wires you’ll be responsible for keeping intact.
micro:bits can receive 3V DC power through the USB dongle, (whether or not it’s also
being supplied by a battery pack, so don’t worry). Power can also be supplied to the 3V
and GND pins (with alligator-clip jumpers if students are sharing from power packs).
Watch out for polarity!

Kitronik UK has ‘ruggedizing’ kits. One is an integral 3V coin-cell backplane called


MI:power, at: https://www.kitronik.co.uk/5610-mipower-board-for-the-bbc-microbit.html
The other is a clear hardshell case with backpack battery pack mount called MI:pro, at:
https://www.kitronik.co.uk/5605-mipro-mountable-case-for-the-bbc-microbit.html

Each has advantages. MI:power provides compact power and even has a tiny ON-OFF
switch (upper left on rear view below) to save the battery life, but it doesn’t protect the
display. MI:pro has a clear-shell case, but fragile wires are still exposed, and the unit
can’t be turned off, unless you take the time after class to pull all the batteries, Ibut
then you have to take time before class to correctly re-install all those batteries again.

Q. When your school places its micro:bit order, what will you recommend for add-ons?
[IMAGE] From top left MI:power rear, MI:pro rear, MI:power front, Mi:pro front

Flashing an auto-test
Quickly review your Course 1 notes on Scratch 3. We will be using similar block coding
in MS Block Editor, with a similar set of block code tiles and a new interface. You may
choose either https://makecode.microbit.org/, for a real-time version Block Editor, or the
legacy version of the Block Editor at https://www.microbit.co.uk/app/#create:xczaux

The legacy version creates a unique instance on their website, and gives you a unique
file name, so you’ll be able to identify the downloaded hex scripts that you created. But
you have to first assemble the block code tiles, then click on ‘run’ to see how they work.
This is the traditional programming sequence, and you’ll recognize it as a teacher, as a
‘discovery’ teaching tool, enticing students to try coding, then ‘run’ it to see if it works.

The real-time version at makecode immediately shows what you’ve stacked together,
which can be disappointing to students if nothing is happening, or if something that was
happening stops happening. It’s just a personal preference, but remembering Scratch 3
uses a Click (flag) to ‘run’ interface, we’ll do our ‘flashing’ from the legacy code version,
that way you can import the hex script at the end of this Course 2 for your test protocol.

Guided Practice
We’ll build a test protocol in MS Block Editor’s legacy version for micro:bit. We’re using
Chrome as a browser, because it’s also on Chromebook when we start programming in
Scratch 3, during the third course. If you don’t have Chrome, go ahead and download it.

Open: https://www.microbit.co.uk/app/#create:xczaux and click on Create Code in the


top bar. Under ‘create code with*’ dropdown, click on Block Editor. It looks like this:
In the first stage of the test protocol, we’ll address the LEDs both by address, and by using
the checkbox matrix. Go to the upper left function bar and click on Basic. In the dropdown
block coding tiles, Click-Hold on ‘forever’ and drag it onto the coding panel in the center.
Next go back to the function bar and click on LED. Click-hold ‘plot x (0) y (0)’ and drag it into
the forever clasp until it clicks in place. Got it? The upper left LED will light and stay on if you
run this script now. Go ahead. In the top left, click on the ‘run’ arrow. After a moment, the
micro:bit emulator in the right panel will light up the upper left (0,0) LED. That was easy!
Click on Basic again, and Click-Hold on ‘pause (ms) (100)’ then drag it under ‘plot x (0) y (0)’
until it clicks into place. Our coding sequence will benefit from pauses, so everything doesn’t
all happen at once. Click on (100) and type in (250), which is 250 ms, or 1/4th-second. If you
ran this change now, nothing would happen on the emulator, because we left the LED on.
Let’s add ‘clear screen’. Go back to Basic and drag ‘clear screen’ to below the ‘forever’ until
it clicks in place above ‘plot x (0) y (0)’. Now run the script again. The blinking LED test.
Quickly add the entire top row of LEDs, with pauses, dragging tiles from the Basic menu:
‘clear screen’ Notice the edits in BOLD, addressing
LEDs by their x( ) and y ( ) coordinates
‘plot x (0) y (0)’ as you move across the 5x5 display,
‘pause (ms) (250)’ and editing the pauses to make them
250 ms. If you ran this script now, the
‘plot x (1) y (0)’ top row of LEDs would light up, one
‘pause (ms) (250)’ after another, then stay that way. Let’s
add the LED matrix address feature.
‘plot x (2) y (0)’ Go back to Basic and Click-Hold ‘’show
leds’, then drag under the last ‘pause
‘pause (ms) (250)’ (ms) (250)’ until it clicks in place. ‘show
‘plot x (3) y (0)’ leds’ will clear the screen, then light up
any of the LEDs that you check off in
‘pause (ms) (250)’ the matrix box. Since we have already
‘plot x (4) y (0)’ tested the (0) row, check all the LEDs
under rows (1), (2), (3) and (4), then
‘pause (ms) (250)’ add one more ‘pause (ms) (250)’.
If you ran the script now, Iwell, go ahead, do it. Click on the arrow ‘run’ again.
The top LEDs light up in sequence, then the bottom four rows flash on, the display clears,
then it starts all over again, just like a Main Street neon sign EAT AT JOE’S! Now we know
how the micro:bit LED display should sequence. Let’s ‘flash’ our LED test onto a micro:bit.
First, get your USB dongle out, plug it into your computer, then into your micro:bit chipset.
Note that no external battery power is required, the USB provides 3V through the dongle.
Your computer will announce that a new device has been found. Click on Open in Folder.
There is your micro:bit with its drive name. You can now drag hex files to your micro:bit, in
the same way as you might drag files onto a thumb drive. That’s the beauty of this legacy
version, it both downloads and uploads scripts that we might want to test on the emulator.
Go ahead and click on MS Block Editor in your browser. Have you got your code ready?
The micro:bit script stack we just built can be saved to
a hex file by clicking on the ‘compile’ button at the top
left. ‘Compile’ only means the MS Block Editor is
converting our stack of code tiles into machine code
that the micro:bit can read. For example, the tile we
read in Block Editor as ‘pause (ms) (250)’ is probably
command ‘time.sleep(0.25)’ in the underlying software,
which compiles into a hex string of: 74 69 6d 65 2e 73
6c 65 65 70 28 30 2e 32 35 29.
Once the script stack has compiled MS Block Editor will
announce your hex file is ready, and then you’ll see a
(unique-file-name.hex) appear as a download. Open
another Explorer window side-by-side and click on
Downloads (under Desktop). You’ll see that .hex file
there. With both Explorer folders open, Click-Hold and
drag the .hex file from Downloads into the micro;bit
folder. You’ll see a yellow light near the USB dongle
blinking, there will be a download pop-up window
showing status, then in a few moments, your micro:bit
will display the test script that we wrote together!
Unplug it from the dongle, plug in a battery pack, and
the micro:bit still works! You’ve ‘flashed’ its memory.

Q. After you successfully get your micro:bit ‘flashed’, how would you achieve this in class?
You should now be ready to attempt an independent practice problem(s) using the
LEDs and each of the gyroscopic compass, tilt and accelerometer functions from the
function bar on the left. Our guided script took a half hour of trial-and-error, so allow
yourself a couple hours and a cup of coffee at the end as a reward. Welcome to the
BBC micro:bit! You’ll find a complete chipset auto-test hex file link below as a go-by.

Independent Practice
Before you begin Independent Practice, we’ll establish metrics you’ll be challenged to.

• Metric 1 will be programming, editing and uniquely naming your own Block Editor script,
to test all the LEDs. You’ll need that skillset as a minimum before you can teach it;
• Metric 2 will be writing program code sequences to test the compass function, and to
coordinate an LED ‘arrow’ display as it rotates about the 5x5 while you turn a circle;
• Metric 3 will be writing program code sequences to test the tilt function, and to
coordinate an LED ‘dot’ display as it rolls toward the corners while you tilt it around;
• Metric 4 will be writing the code and a script for a 1-hour lesson plan on micro:bit.

---

• Computer Science Fundamentals course


• A 14 week Introduction to Computer Science course

This lesson has been developed in collaboration with K12 Maker Integration
I need to know...

• About getting started


• How to buy a micro:bit or accessory
• About getting support
• More about the Micro:bit Educational Foundation
• The Privacy Policy
• The Terms of Use

I am a...

• Student
• Teacher
• Developer
• Robot

I would like to be a...

• Coder
• Accessory Maker
• Reseller
• Part of the Foundation

© Copyright Micro:bit Educational Foundation

You might also like