admin管理员组文章数量:1123407
I'm trying to communicate with my Arduino nano via Python, but it doesn't work. The Python code works just fine with my other Arduino. The nano works just fine with serial communication via the Arduino IDE. I'm a little clueless as all the elements seem to work for them self. Arduino Code:
void setup() {
Serial.begin(9600);
pinMode(LED_BUILTIN,OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
}
void loop() {
if (Serial.available()>0) {
int i = Serial.read();
digitalWrite(LED_BUILTIN,HIGH);
delay(1000);
digitalWrite(LED_BUILTIN,LOW);
}
}
Python:
import serial
import time
arduino2 = serial.Serial(port='COM12', baudrate=9600, timeout=.1)
time.sleep(1)
arduino2.write(str.encode("u"))
Edit: I Know there is some communication between Python and the nano as it blinks (really short, not the 1 second) both when arduino2 gets initialized and when "u" is written to it.
本文标签: serial portWhy can39t Python communicate with the Arduino nano and Arduino IDE canStack Overflow
版权声明:本文标题:serial port - Why can't Python communicate with the Arduino nano and Arduino IDE can? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736568914a1944744.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论