Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
BBC microbit digital measuring tape (code release)
# with this code you need to make hardware changes to sensor
# or you can add on code to disable pull resistor on pin16
from microbit import *
remind = 0
remind_1 = 0
counter = 0
display.scroll("Hello Girls")
sleep(1000)
display.clear()
display.show(Image.HAPPY)
sleep(2000)
while True:
if ((button_a.is_pressed() == True) & (remind == 0)):
if (pin16.read_digital() == True):
remind = 1
elif (pin16.read_digital() == False):
remind = 2
if ((pin16.read_digital() == True) & (remind == 2)):
remind = 1
counter = counter + 1
if ((pin16.read_digital() == False) & (remind == 1)):
remind = 2
counter = counter + 1
if ((button_a.is_pressed() == False) & (remind > 0) & (remind_1 == 0)):
remind = 3
remind_1 = 1
counter = ((counter * 5)/10)
display.clear()
display.show(str(counter))
display.scroll("cm")
sleep(1000)
display.clear()
display.show(Image.HAPPY)
if (remind_1 == 1):
if (button_b.is_pressed() == True):
remind = 0
remind_1 = 0
counter = 0
if (remind_1 == 1):
if (button_a.is_pressed() == True):
display.clear()
display.show(str(counter))
display.scroll("cm")
sleep(1000)
display.clear()
display.show(Image.HAPPY)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.