我已经将 Arduino 设置为在收到“S”字节时发送数据。这适用于 Arduino 串行监视器。不过,我正在 Python 上绘制数据,使用 Pyserial 联系串行端口。这是我的 Arduino 草图,以明确我的意思:
#include <eHealth.h>
unsigned long time;
unsigned long interval = 8;
byte serialByte;
// The setup routine runs once when you press reset:
void setup() {
Serial.begin(9600);
}
// The loop routine runs over and over again forever:
void loop() {
if(Serial.available()>0){
serialByte = Serial.read();
if(serialByte == 'S'){
while(1){
float ECG = eHealth.getECG();
time = time + interval;
Serial.print(time);
Serial.print(" ");
Serial.print(ECG, 3);
Serial.println("");
if(Serial.available()>0){
serialByte = Serial.read();
if (serialByte …Run Code Online (Sandbox Code Playgroud)