用串口向32发信息,32代码都没问题,但是串口一直发不出去,一点反应没有,波特率都是对的,代码有问题吗?
-
import sensor, image, time
from machine import UART
import jsonred_threshold = (100, 34, 11, 127, -28, 54)
sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.RGB565) # use RGB565.
sensor.set_framesize(sensor.QQVGA) # use QQVGA for speed.
sensor.skip_frames(10) # Let new settings take affect.
sensor.set_auto_whitebal(False) # turn this off.
clock = time.clock() # Tracks FPS.uart = UART(1,115200)
uart.init(115200, bits=8, parity=None, stop=1)
def find_max(blobs):
max_size=0
for blob in blobs:
if blob[2]*blob[3] > max_size:
max_blob=blob
max_size = blob[2]*blob[3]
return max_blobwhile(True):
img = sensor.snapshot() # Take a picture and return the image.
blobs = img.find_blobs([red_threshold])
if blobs:
max_blob = find_max(blobs)
x_error = max_blob[5]-img.width()/2
y_error = max_blob[6]-img.height()/2
img.draw_rectangle(max_blob[0:4]) # rect
img.draw_cross(max_blob[5], max_blob[6]) # cx, cy
output_str="%d,%d"% (x_error,y_error) #方式1
uart.write(output_str+'\r\n')
print('you send:',output_str)
-
用USB转串口模块看OpenMV的串口数据。