Using the micro:bit to inspire students

Luke Spademan

70%

More girls said they would
choose Computing as a school subject
after using the micro:bit

Microbit Educational Foundation
https://microbit.org/research/

Using the micro:bit to inspire students

Luke Spademan

What is a micro:bit?

Micro:bit

Micro:bit

Micro:bit features

  • 2 buttons
  • 25 LEDs
  • edge connector
  • radio
  • compass
  • accelerometer
  • USB port
  • reset button
  • battery socket

My Story

My Story

  • In 2015 micro:bits were given to all UK years 7s
  • I was in year 8
  • I went to PyCon UK
  • Micro:bits were being given out to attendes
  • My dad and I got a micro:bit each
  • I made a calulator that send answers to the other micro:bit
  • I gave a lightenting talk about the project

My Story

  • I made a game of conenct 3
  • I added a colour display on a raspberry pi with a sense hat
  • I gave a talk at PyCon UK the next year about the project

Mu

Nicholas Tollervey

Mu

“a simple Python editor for beginner programmers”

Mu

  • Simple text editor
  • Easy to use
  • No bloat
  • Built for the micro:bit

Mu's Features

  • Python Editor
  • Built in micro:bit flasher
  • REPL
  • Built in plotter
  • Built in debugger

How does this work?

First non-micro:bit program


  print("Hello, World!")
            

  Hello, World!
            

First micro:bit program


  from microbit import *
  display.scroll("Hello, World!")
            
microbit scrolling hello world

“If the micro:bit is so great, why do I need a robotic arm?”

The same benefits but more

  • You're moving a physical object
  • You wrote the code to make it move
  • More relatable to future applications

Demos

  • Micro:bit is small
  • Robotic arm is bigger
  • Visual and Dramatic

Example

Equipment

Equipment

Items Link Price (€)
Robotic Arm lspade.xyz/l/roboticarm 15,08
Breadboard lspade.xyz/l/breadboard 2,75
Jumper Wires lspade.xyz/l/jumperwires 3,97
Edge Connector lspade.xyz/l/edgeconnector ~5,81

Setup

Servo Calibration


from microbit import *

angle = 90

while True:
  if button_a.was_pressed():
    angle += 5
    pin0.write_analog(angle)
    print(angle)

  if button_b.was_pressed():
    angle -= 5
    pin0.write_analog(angle)
    print(angle)

        

Code

Code: Setup


from microbit import *

servos = [pin0, pin1, pin2, pin16]
min_angles = [5, 50, 5, 5]
max_angles = [180, 130, 145, 180]

states = [5, 50, 5, 5]  # position of each servo

s = 0  # current servo
d = 5  # angle increment
        

Code: Loop


while True:
  if button_a.is_pressed():
    states[s] += d
    if states[s] > max_angles[s] or states[s] < min_angles[s]:
      states[servo] -= d
      d *= -1  # start moving in the other direction
    servos[s].write_analog(states[s])
    sleep(100)  # wait 100ms before checking for press

  if button_b.was_pressed():
    s += 1
    if s == 4:
      s = 0
    d = 5

        

Live Demo...

Other Projects

LEDs


from microbit import *

while True:
  pin1.write_digital(1)
  sleep(500)
  pin1.write_digital(0)
  sleep(500)
          

LEDs & Touch


from microbit import *

while True:
    if pin0.is_touched():
        pin1.write_digital(1)
    else:
        pin1.write_digital(0)
          

LEDs & Touch

Connect 3

Hacking the L-Light

Morse Code


from microbit import *
import music

lookup = {'.-': 'A', '-...': 'B', '-.-.': 'C', ...}

u = 75  # one time unit in ms
last = running_time()  # records last press
                       # (for detecting end of letter)
code = []  # current morsecode input
          

Morse Code


def handler(symbol, duration):
  if running_time() - last > 3*u:  # morse code letters
                                   # have 3 unit gap inbetween
    code = []
  display.show(symbol)
  code.append(symbol)

  music.pitch(300, duration, wait=True)
  last = running_time()
  sleep(u)
          

Morse Code


while True:
  if button_a.is_pressed():
    handler(".", u)
  elif button_b.is_pressed():
    handler("-", 3*u)
  else:
    if running_time() - last > 3*u:
      v = lookup.get("".join(code), " ")  # show nothing if
                                          # input is invalid MC
      display.show(v)
          

helloworld.cc