Skip to content

Instantly share code, notes, and snippets.

@VlastimilHovan
Created November 30, 2016 18:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VlastimilHovan/2f904cb32be20d808481e04f5dd7fe0c to your computer and use it in GitHub Desktop.
Save VlastimilHovan/2f904cb32be20d808481e04f5dd7fe0c to your computer and use it in GitHub Desktop.
BBC microbit pulse rate monitor (code release)
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