the BBC micro:bit Getting started...
Transcript of the BBC micro:bit Getting started...
Getting started with the BBC micro:bitBrunswick | 29th March, 2019
About us
Nathan Alison
Professional Learning CoordinatorDigital Learning and Teaching Victoria (DLTV)
Sanjin Dedic
STEM Educator (KIOSC Swinburne) Specialising in physical tech and Python.
2
Schedule
9:30am Why do physical tech?
9:40am First programs on the micro:bit:●“Hello”, respond to button●Countdown●Reaction time challenge
10:45am Morning tea
11:00am Coding for Computational Thinking(separate Python and visual)
3
Schedule
12:30pm Lunch
1:10pm Curriculum linksDesign thinking
1:30pm Coding for Physical Tech(separate Python and visual)
2:50pm Wrap upResources whirlwind
3:00pm Finish4
Discuss in your group
What does your school do in the area of:
● coding● physical tech (eg. electronics, robotics)● implementing the Digital Technologies
curriculum
5
Why do physical tech?
6
● Several lines of code can do something that is tangible and useful:
○ Wearable tech
○ Home automation
○ Alarm Systems
○ Remote control
Doing more with less!
7
● sound
● light
● button, knob, slider
● touch
● angle, direction
● motion, distance
● moisture, pH
● temperature, humidity
8
Many options for interaction
● LEDs
● scrolling text
● motor, fan
● servo motor
● speaker / headphones
● graphics (Scratch)
INPU
TS
OUTP
UTS
● Typical programs are mouse/keyboard inputs, pixels / audio outputs
● Physical tech allows you to interact with the physical world, sense the environment and move stuff around.
● When faced with a problem, students will come up with more solutions if familiar with physical tech
More possibilities of solving real world problems
9
● Typically logic errors (code works but program misbehaves) are easier to understand and easier to troubleshoot
Better understanding of program logic
10
Microcontrollers and the BBC micro:bit
11
What is a microcontroller?
A computer on a microchip:
● It is programmable .● It can be connected to sensors and output
devices.● It has a clock, a CPU as well as memory.
12
Where are microcontrollers used?
13
● affordable (~$25),
● simple 5x5 LED display and on-board sensors,
● visual code + JavaScript + Python,
● no need to install software or drivers,
● 5 big pins to use directly,
● many options for expansion:○ robots
○ physical tech, sensors
The micro:bit - classroom game changer?
14
15image: microbit.org
First programs(all together)
16
● The micro:bit should appear like a USB stick on your computer.
● The micro:bit now has power. It will run whatever program was last put onto it.
Connect USB lead
17
makecode.microbit.org visual and JavaScript*
python.microbit.org Python
● These environments are completely online.
● No login (pros and cons).
* Actually Microsoft TypeScript.
Coding with the standard environment
18
“Hello World”
19
● Classic first program.
● Get the micro:bit to scroll “Hello” or similar.
● If button A is being pressed, show happy face.
● Otherwise, show sad face.
Respond to button press
20
● Start by counting up from 0 to 10 on screen.
● Then scroll “BLAST OFF!”
● Now, can you make it count down?
Countdown
21
● Speed up or slow down as it reaches the end.
● Use pixels on the screen to illustrate the countdown.
Tinkering with this challenge
22
● How fast can you press the button with no warning?
Reaction time challenge
23
● How fast can you press the button with no warning?
Reaction time challenge
24
Scroll “Get ready...”Wait for unpredictable timeShow a symbol to start the challenge
● How fast can you press the button with no warning?
Reaction time challenge
25
Scroll “Get ready...”Wait for unpredictable timeShow a symbol to start the challengereactionTime ← 0
● How fast can you press the button with no warning?
Reaction time challenge
26
Scroll “Get ready...”Wait for unpredictable timeShow a symbol to start the challengereactionTime ← 0REPEAT until button B is pressed
Count up reactionTimeEND REPEAT
● How fast can you press the button with no warning?
Reaction time challenge
27
Scroll “Get ready...”Wait for unpredictable timeShow a symbol to start the challengereactionTime ← 0REPEAT until button B is pressed
Count up reactionTimeEND REPEATScroll “Your time: ”, reactionTime
● Put in a loop so that the program starts again, without you having to press reset.
● Limit the game to exactly 3 rounds, then say “Game over”.
● Store the score for each round, then provide the player with an average score when all the rounds are over.
● Make a “hotseat” challenge for 2 players.
Tinkering with this challenge
28
Morning tea
29
Coding continued(Visual and Python separate)
30
● First micro:bit takes a temperature reading every second, and transmits it via radio.
● Second micro:bit displays the value whenever it is received.
Remote temperature readout
31
● micro:bit makes wireless communication ridiculously easy!
● Buzz-in game show.
● “Infection” game.
Imagine the possibilities
32
● Each time user presses Button A:
○ Choose a random number between 1 and 100.
○ Calculate the sum of all the numbers up to that number.
○ Display the number and the sum.
A bit of Maths
33
● User thinks of a number between 1 and 100.
● micro:bit takes a guess.
● User presses A to indicate lower, or B to indicate higher.
● micro:bit keeps guessing until it gets the right number.
Number guessing
34
● User thinks of a number between 1 and 100.
● micro:bit takes a guess.
● User presses A to indicate lower, or B to indicate higher.
● micro:bit keeps guessing until it gets the right number.
Number guessing
35
Scroll “Think of a number...”
● User thinks of a number between 1 and 100.
● micro:bit takes a guess.
● User presses A to indicate lower, or B to indicate higher.
● micro:bit keeps guessing until it gets the right number.
Number guessing
36
Scroll “Think of a number...”bottom ← 0top ← 100
● User thinks of a number between 1 and 100.
● micro:bit takes a guess.
● User presses A to indicate lower, or B to indicate higher.
● micro:bit keeps guessing until it gets the right number.
Number guessing
37
Scroll “Think of a number...”bottom ← 0top ← 100REPEAT forever
guess ← average of bottom and topScroll “Is it “, guess, “?”
END REPEAT
● User thinks of a number between 1 and 100.
● micro:bit takes a guess.
● User presses A to indicate lower, or B to indicate higher.
● micro:bit keeps guessing until it gets the right number.
Number guessing
38
Scroll “Think of a number...”bottom ← 0top ← 100REPEAT forever
guess ← average of bottom and topScroll “Is it “, guess, “?”Wait until button A or B is pressedIf Button A pressed
top ← guessELSE
bottom ← guessEND IF
END REPEAT
● A “brick” pixel falls down the screen.
● The player must avoid the bricks.
Raining bricks game
39
0 1 2 3 4
01
34
2
y-po
sitio
n
x-positionBrick will start at one of these pixels.
Player stays in the bottom row.
tinyurl.com/y6rzx38j
Brick
40
brickY ← 0 Start at top of display.brickX ← random number from 0 to 4REPEAT forever
Wait for 200 ms A short pause every time we loop.Unplot pixel at (brickX, brickY) Before moving the brick, turn off the
LED at its previous position.Add 1 to brickY Move down 1 pixel.IF brickY > 4 If brick has gone past the bottom...
brickY ← 0 ...go back to the top,brickX ← random number from 0 to 4 and find a new position to start.
END IFPlot pixel at (brickX, brickY) Turn on the LED at the new position.
END REPEAT
Player
41
playerX ← 2 Start in the middle at the bottom.REPEAT forever (The same loop from the brick code.)
Wait for 200 ms (The same wait from the brick code.)Unplot pixel at (playerX, 4) Before moving the player, turn off the
LED at their previous position.IF button A is pressed
Minus 1 from playerX END IFIF button B is pressed
Add 1 to playerX END IFPlot pixel at (playerX, 4) Turn on the LED at the new position.
END REPEAT
Lunch
42
3 strands of the Digital Technologies curriculum
43
Digital Systems strand - Primary Years
44
● The micro:bit is a very small computer, with deliberately limited inputs and outputs.○ Discuss input, processing, storage, output.○ Compare purpose of small microcontrollers with regular
desktop or laptop computers.
Digital Systems strand - Secondary Years
45
● digitaltechnologieshub.edu.au/teachers/lesson-ideas/morse-code-network
or
digitaltechnologieshub.edu.au and search “Morse Code”
○ Use alligator clips to connect micro:bits together into an “Internet”.
○ Use Morse Code as a metaphor.
● microbit.nominetresearch.uk○ Uses the micro:bit’s radio capabilities.
○ Covers different aspects of networks(eg. retransmission and ACK packets).
○ Includes games to make.
46
Digital Systems strand - Secondary Years
● micro:bit can be used to gather (and process) data.
● Use arrays to store data over time.
● How to get data off it?
1. Scroll on screen and use a button to advance.
2. Serial communication. Requires installing software on a computer. See makecode.microbit.org/device/serial
3. Bluetooth to mobile app. eg. Bitty Data Logger (bittysoftware.com/apps.html) for Android and iOS.
47
Data and Information strand
● Practice the Design process and Design Thinking:
○ Coding projects
○ Physical tech projects
48
Creating Digital Solutions strand
Design thinking
49
Patient 3Patient 2Patient 1
Physical tech:raw components
54
● Make a simple circuit with alligator clips.
● The micro:bit is powering the LED with 3V.
55
Power an LED
2.2 k𝛺
● Adjust the circuit so that power comes from Pin 0.
● Write a program to flash the LED.
56
Flash an LED
2.2 k𝛺
Physical tech:electronic modules
57
● Less messy than raw components.
● More safety and control built in.
● Use expansion boards to access more pins on the micro:bit.
58
Why modules?
● Hook up a light sensor.
● Hook up an LED.
● The LED goes on when the light level gets low.
59
Light up the dark
60
Pick another module and try it!
● Create a hand clap-activated light and a fan for a home model.
61
Clap switch
Sound Sensor picks up clap.
Red LED used for light.
Fan.
micro:bit placed in BOSON Expansion Board.
Rotation Sensor controls fan.
tinyurl.com/yyv69j78
● Create a hand clap-activated light and a fan for a home model.
62
Clap switch
tinyurl.com/yyv69j78
Resources whirlwind
63
makecode.microbit.org visual and JavaScript*
scratch.mit.edu/microbit Scratch 3 supports micro:bit.
Special software must be installed, then micro:bit is tethered - parallel programming on micro:bit and computer screen.
Coding environments (visual)
64
* Actually Microsoft TypeScript.
python.microbit.org Online Python editor
codewith.mu Offline Python editor
(Download and install on computer.)
Coding environments (Python)
65
Grok learning / Australian Computing Academy
66
aca.edu.au/resources Australian Computing Academy have created mini challenges.
Run inside the Grok Learning platform. Free for all Australian students Years 3-8.
Visual (Blockly) and Python.
microbit.org/ideas Example projects
microbit.org/teach Links to lessons / courses from:
● Microsoft● code.org● IET (Institution of Engineering
and Technology)● Launch Computer Science● Project Lead the Way
Ideas, projects, lessons
67
microbit.org/global-challenge A worldwide challenge related to global development goals.
Ideas, projects, lessons
68
tinyurl.com/y422cjdtVisual Edition (Google Doc)
tinyurl.com/y2utzsrbVisual Edition (PDF)
tinyurl.com/y3rqanj5JavaScript Edition (Google Doc)
tinyurl.com/yxu5v7btJavaScript Edition (PDF)
Ideas, projects, lessons
69
Physical Tech from Go to Whoa!
● 6 activities with micro:bit only.
● 5 activities adding Boson Starter Kit.
● 5 activities adding Boson Science Kit.
● Kitronik Inventor’s Kit○ includes required components and breadboard○ guide includes a series of projects○ ZIP LEDs add-on available
● exhi:bit○ alternative breadboard prototyping system○ allows permanent installation with soldering○ daughter boards can be swapped out○ pre-built daughter boards for specific experiments
Hardware add-ons - breadboarding
70
● 4tronix Playground○ a range of “gizmos” can be attached with audio jacks
● BOSON○ a range of modules can be attached with connectors○ Lego-compatible and magnetic○ also takes Gravity modules - a massive range of advanced
sensors and actuators
Hardware add-ons - electronic modules
71
● Grove Inventor Kit○ a range of modules can be attached with connectors
● Monk Makes○ a range of modules can be attached with alligator clip leads○ includes relay board to switch a higher-power circuit
● Weather:bit○ soil, humidity, temperature, pressure, altitude built in○ connections for SparkFun micro:climate kit
Hardware add-ons - electronic modules
72
● Kitronik MOVE mini buggy○ add-ons for bulldozer, tipper trailer, line following
● DFRobot Max:bot○ line following○ front-side collision sensors○ colourful LED strips
● SparkFun Micro:bot kit○ line following○ side motors for combat
Hardware add-ons - rover robots
73
● 4tronix bit:bot○ colourful LED strips○ add-ons for pen holder, ultrasonic (distance) sensor
● Tobbie II (coming soon)○ hexiped robot shell
● Or build your own using parts and○ eg. SparkFun moto:bit○ eg. SparkFun gator:bit
Hardware add-ons - rover robots
74
● :GAME ZIP 64○ hand-held game controller with 8x8 LED array
● micro:arcade kit○ traditional arcade game controls
Hardware add-ons - game interface
75
● e-Textiles kit○ conductive thread○ LEDs with resistors built-in
● Klip Halo○ breaks out micro:bits pins in a circle
Hardware add-ons - wearable tech
76
● micro:pixel○ 8 x 3 array of LEDs
● ZIP Halo○ circular loop of LEDs
● Waveshare LCD display○ full colour 1.5 inch display
Hardware add-ons - displays
77
● bit:2:pi○ allows micro:bit to interface with some Raspberry Pi hats
● Hummingbird adapter○ allows micro:bit to control old Hummingbird Arduino board and
reuse components○ (NOTE: new Hummingbird Bit now available.
Arduino board can be redundant.)
Hardware add-ons - compatibility
78
Wrap up
79
DLTVUpcoming events
BBC micro:bit
● Do more with the BBC micro:bit (Fri, 14 June)
Python
● Computational Thinking in Python (Fri, 7 June)
● Wrangling data with Python (Semester Two)
Inclusive Literacy and Numeracy tools for all (Fri, 16 August)
80
DLTVOther planned events
Metro and regional workshops (Term 2-4)
● DigiTech Across the Curriculum: hands-on skills and Design Thinking
● Digital Technologies Curriculum and Skills (Australian Computing Academy)
Object-oriented day (Semester Two)
Literacy through interactive fiction and games (Semester Two)
VCE new Study Design day (Semester Two)
81