logo

之前串口没有问题,今天串口上传数据乱码。会不会是硬件问题

2021-04-06 16:57
5
简码物联

# Single Color RGB565 Blob Tracking Example

#

# This example shows off single color RGB565 tracking using the OpenMV Cam.

import sensor, image, time, math

from pyb import UART

threshold_index = 0 # 0 for red, 1 for green, 2 for blue QVGA320

thresholds = [(100, 100, 0, 3, 3, 0), # generic_red_thresholds

(255,255), # generic_green_thresholds 30,255

(0, 30, 0, 64, -128, 0)] # generic_blue_thresholds RGB565 GRAYSCALE

sensor.reset()

sensor.set_pixformat(sensor.GRAYSCALE) #sensor.GRAYSCALE

sensor.set_framesize(sensor.VGA) #sensor.VGA

sensor.skip_frames(time = 2000)

sensor.set_auto_gain(False) # must be turned off for color tracking

sensor.set_auto_whitebal(False) # must be turned off for color tracking

clock = time.clock()

uart = UART(3,57600)

mx=0

my=0

while(True):

clock.tick()

img = sensor.snapshot()

for blob in img.find_blobs([thresholds[1]], pixels_threshold=10, area_threshold=10, merge=True):

if blob.cx() > 100 :

img.draw_rectangle(blob.rect())

img.draw_cross(blob.cx(), blob.cy())

#str(blob.cx())+','+str(blob.cy())

uart.write('{'+str(blob.cx())+','+str(blob.cy())+'}')

print('{'+str(blob.cx())+','+str(blob.cy())+'}')

#uart.write(str(blob.cx())+','+str(blob.cy())+';')

16168782-6b82-4edd-af14-2c38e9f65243.jpg
9db113d8-51fe-4825-abde-2840b2445330.jpg
2021-04-07 12:09
5
简码物联

解决了,串口接地就没有乱码了。

2021-04-07 20:04
9
owgv

请问怎么可以把数据传输出去呢