小编haw*_*kar的帖子

使用 Python 的 Pyserial 将字符发送到 Arduino 串行端口

我已经将 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)

python serialization serial-port matplotlib

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

matplotlib ×1

python ×1

serial-port ×1

serialization ×1