Created
November 30, 2016 18:30
-
-
Save VlastimilHovan/2f904cb32be20d808481e04f5dd7fe0c to your computer and use it in GitHub Desktop.
BBC microbit pulse rate monitor (code release)
This file contains 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
from microbit import * | |
analog_0 = 0 | |
counter = 0 | |
previous_running_time = 0 | |
target = 20000 | |
pulse = 0 | |
remind = 0 | |
while True: | |
current_running_time = running_time() | |
analog_0 = pin0.read_analog() | |
if (remind == 0): | |
if (analog_0 >= 920): | |
display.show(Image.HEART) | |
counter = counter + 1 | |
remind = 1 | |
if (remind == 1): | |
if (analog_0 < 920): | |
display.clear() | |
remind = 0 | |
if ((current_running_time - previous_running_time) >= target): | |
counter = counter * 3 | |
display.scroll("%d bpm" % (counter), delay=100,) | |
counter = 0 | |
previous_running_time = running_time() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment