Created
December 1, 2016 20:06
-
-
Save VlastimilHovan/bbe1c826b327ea067b8f7450285a98d3 to your computer and use it in GitHub Desktop.
BBC microbit digital measuring tape (code release)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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