ACDT_project2_final / read_bpm.py
Jiwoo77's picture
Upload read_bpm.py
a7a3a5f verified
raw
history blame contribute delete
409 Bytes
# read_bpm.py
import threading
import serial
bpm_value = 0
def read_serial():
global bpm_value
ser = serial.Serial('COM9', 9600)
while True:
try:
line = ser.readline().decode().strip()
if line.isdigit():
bpm_value = int(line)
except:
continue
t = threading.Thread(target=read_serial, daemon=True)
t.start()