Using the micro:bit to inspire students

Luke Spademan

What is a micro:bit?

Micro:bit

Micro:bit

Mu

Mu

“a simple Python editor for beginner programmers”

Mu

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

How does this work?

First programs comparison

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

Expectation

Reality

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 Ideas

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)