openmv和arduino通信,为什么能接收到信息但无法发送信息
-
//openmv端代码
import time from pyb import UART uart = UART(3, 9600,timeout=10000000,read_buf_len=1) while True : receive = uart.read(1) #读到一个数据,把一个数据赋值给receive print(receive) #读到8会变成b'8' time.sleep_ms(200) if receive == b'8' :#与arduino通讯 print("receive") time.sleep_ms(2000) uart.write('n')#发送完成信号 print("transmit") break
//arduino端代码 #include <SoftwareSerial.h> SoftwareSerial BTserial(5,6); // 建立SoftwareSerial对象,RX引脚5, TX引脚6 int b=0; void setup() { Serial.begin(9600); BTserial.begin(9600); // HC-06 默认波特率 9600 } void loop() { int a = 1; if (a = 1) //a区,收到A板发出的消息,左采摘 { switch (b) { case 0: delay(3000); BTserial.write("8"); b = 30; //给openmv发一次消息 Serial.println("transmit"); delay(1000); } if (BTserial.available()) //读取open mv的消息 { char c = BTserial.read(); Serial.println(c); delay(1000); if (c == 'n') { delay(1000); Serial.println("end"); b = 0; //b恢复 } } } }