You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
394 B
21 lines
394 B
4 years ago
|
from pulsesensor import Pulsesensor
|
||
|
import time
|
||
|
|
||
|
|
||
|
#this code assumes you have an MCP3008 with the analog heartbeat sensor on channel 0
|
||
|
|
||
|
p = Pulsesensor(channel=0, device=0)
|
||
|
p.startAsyncBPM()
|
||
|
|
||
|
try:
|
||
|
while True:
|
||
|
bpm = p.BPM
|
||
|
if bpm > 0:
|
||
|
print("BPM: %d" % bpm)
|
||
|
else:
|
||
|
print("No Heartbeat found")
|
||
|
time.sleep(1)
|
||
|
except:
|
||
|
p.stopAsyncBPM()
|
||
|
|