串口接收一字符再拍照,并输入一次拍一张?
-
我想用arduino板子想OPENMV发送一字符让它拍照,且输入一次拍一张,如何实现?代码如下:
# 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 sensor, image, pyb,time from pyb import UART BLUE_LED_PIN = 3 # 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, 9600, timeout_char=1000) sensor.reset() # Initialize the camera sensor. sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE sensor.set_framesize(sensor.VGA) # or sensor.QQVGA (or others) sensor.skip_frames(time = 500) # Let new settings take affect. pyb.LED(BLUE_LED_PIN).on() sensor.skip_frames(time = 500) # Give the user time to get ready. pyb.LED(BLUE_LED_PIN).off() count = 0; while(True): if uart.any(): a = uart.readline().decode() if a == "OK\r\n": count = count + 1 sensor.snapshot().save("%d.jpg"%(count)) # or "example.bmp" (or others) uart.write("Finish") pyb.LED(BLUE_LED_PIN).on() time.sleep(100) pyb.LED(BLUE_LED_PIN).off() a = "\n"; else: sensor.snapshot() time.sleep(100)
运行时,显示错误
-
有大神帮忙解决一下么?万分感谢!
-
你用Arduino发送的数据的可能不是字符串。
建议先用OpenMV 串口调试扩展板和星瞳串口助手测试。