More girls said they would
choose Computing as a school subject
after using the micro:bit
Microbit Educational Foundation
https://microbit.org/research/
“a simple Python editor for beginner programmers”
print("Hello, World!")
Hello, World!
from microbit import *
display.scroll("Hello, World!")
“If the micro:bit is so great, why do I need a robotic arm?”
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 |
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)
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
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
from microbit import *
while True:
pin1.write_digital(1)
sleep(500)
pin1.write_digital(0)
sleep(500)
from microbit import *
while True:
if pin0.is_touched():
pin1.write_digital(1)
else:
pin1.write_digital(0)
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
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)
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)