串口接收和摄像头冲突
-
# UART Control # # This example shows how to use the serial port on your OpenMV Cam. Attach pin # P4 to the serial input of a serial LCD screen to see "Hello World!" printed # on the serial LCD display. import time from pyb import UART import sensor, image, time from pyb import UART import json import pyb threshold_index = 0 # 0 for red, 1 for green, 2 for blue thresholds = [(5, 100, 30, 127, 0, 80), # generic_red_thresholds (5, 100, -127, -20, 0, 80), # generic_green_thresholds (5, 100, -20, 30, -127, -20)] # generic_blue_thresholds led = pyb.LED(3) sensor.reset() sensor.set_pixformat(sensor.RGB565) # grayscale is faster sensor.set_framesize(sensor.QQVGA) sensor.skip_frames(time = 2000) clock = time.clock() # Always pass UART 3 for the UART number for your OpenMV Cam. # The second argument is the UART baud rate. For a more advanced UART control # example see the BLE-Shield driver. uart = UART(3, 115200) sensor.set_auto_gain(False) # must be turned off for color tracking sensor.set_auto_whitebal(False) # must be turned off for color tracking uart = UART(3, 115200) flag = 0 cnt = 0 x = 0 y = 0 while(True): #output = "%d"%(3) #uart.write(output) clock.tick() if uart.any(): a = uart.readline().decode().strip() print(a) flag = int(a) print(flag) if flag == 1: img = sensor.snapshot().lens_corr(1.8) # uart.write("Hello World!\r") # time.sleep(100) 发送的数据为 1 或者 2 单片机端代码 sprintf(printbuff1, "1\r\n"); //显示 uart_putstr(UART1,printbuff1);
会出现图中的错误,怎么解决呢
-
你应该用串口助手试一下,我不知道你单片机的函数有没有混进去什么奇怪的东西。