logo

关于串口通信问题???大佬帮忙解决一下

2022-08-16 18:25
K
hxcb
import sensor, image, time,pyb,math
from pyb import UART
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
uart = UART(3,9600,timeout=1000)


clock = time.clock()

while(True):
    clock.tick()
    img = sensor.snapshot()    
    if uart.any():
        print('OK')
        d=uart.readchar()
        print(d)
        if(d=='A'):
            pyb.LED(2).on()

arduino代码

void setup()
{
Serial.begin(9600);
}
void loop()
{  
     Serial.write('A');
     delay(5000);
 
     Serial.write('B');
     delay(5000);   
}

在电脑上arduino串口可以看到发送数据,但是openmv接收不到没有信息发过来

2022-08-16 20:59
I
网红小智智 星瞳科技

你的线是怎么连接的。

2022-08-16 21:14
K
hxcb

arduino的10 11 软串口接的p4 p5 然后gnd相连 那两个通信线对调了还是没反应

2022-08-17 20:45
I
网红小智智 星瞳科技

Arduino的Serial 是0和1,你用10和11错了。

参考:

https://book.openmv.cc/MCU/serial1.html