各位大神们大家好,关于串口通信我有一些疑问想问下大家,下面的程序是扫描识别二维码的,其中print(code)指的是在IDE中打印二维码的内容,假设说我的二维码的内容为‘123’,其中的123是我在草料二维码中直接打的,我也不清楚是字符还是数字,但我猜应该是字符,当我想要把这串信息发送给单片机的时候,请问我应该在用uart.write(code)还是用什么呢?麻烦大家了!
import sensor, image
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA) # can be QVGA on M7...
sensor.skip_frames(30)
sensor.set_auto_gain(False) # must turn this off to prevent image washout...
while(True):
img = sensor.snapshot()
img.lens_corr(1.8) # strength of 1.8 is good for the 2.8mm lens.
for code in img.find_qrcodes():
print(code)https://forum.singtown.com/topic/1102/%E5%85%B3%E4%BA%8E%E4%BA%8C%E7%BB%B4%E7%A0%81%E8%AF%86%E5%88%AB%E7%9A%84%E7%96%91%E9%97%AE/4
你为什么总是重复提问?
@kidswong999 哈哈哈,大神不好意思啊,我已经找到了解决的办法了,你看我下面的方法,是不是炒鸡简洁哈哈哈,我一开始用的是这个data = code.payload()
print(data)
uart.write(data),但是发现让主单片机处理这串字符太过于麻烦,然后我就直接让OPENMV自己先消化一下,总之谢谢你啦!!!
for code in img.find_qrcodes():
data = code.payload()
print(data)
if(data=='123'): #123代表红绿蓝
uart.write('1')
time.sleep(100)
if(data=='132'):
uart.write('2')
time.sleep(100)
if(data=='213'):
uart.write('3')
time.sleep(100)
if(data=='231'):
uart.write('4')
time.sleep(100)
if(data=='312'):
uart.write('5')
time.sleep(100)
if(data=='321'):
uart.write('6')
time.sleep(100)