Arduino与Python之间的串行通信

Arduino与Python之间的串行通信,python,arduino,Python,Arduino,我试图在Arduino和Python之间建立通信。我想从arduino以字节的形式编写int值,并用Python读取它们,但我需要一些帮助来做到这一点 这是我的Arduino代码: long prev = millis(); void setup(){ Serial.begin(115200); } void loop(){ long current = millis(); if(current - prev > 5000){ Serial.write(32760)

我试图在Arduino和Python之间建立通信。我想从arduino以字节的形式编写int值,并用Python读取它们,但我需要一些帮助来做到这一点

这是我的Arduino代码:

long prev = millis();

void setup(){
Serial.begin(115200); 
}

void loop(){
 long current = millis(); 
  if(current - prev > 5000){
     Serial.write(32760); 
     prev = millis();
  }
}
下面是我的Python代码:

import serial

arduino = serial.Serial('/dev/ttyUSB1', 115200)
while True:
    data = arduino.read(); 
    print("number: ", int(data.encode('hex'),16));
Python端的输出是,
('number:',63736)
,这与预期不同

我尝试使用
ord()
函数打印它,但没有任何效果。 提前感谢,任何帮助都将不胜感激