问题就是,我openmv插上电脑USB供电的时候,arduino那边接受到我扫码的都是正常的,我脱机后,通上电,arduino那边会接受0,但是openmv此时还在扫码,没发送信息过去
import time
import sensor, image, time
import json
import pyb
from pyb import UART
global zuo,zhong,you
zuo=0
zhong=0
you=0
yellow_threshold = ( 46, 100, -68, 72, 58, 92)
red_threshold =(39, 4, 67, 43, -29, 69)#红色颜色阈值
green_threshold = (28, 4, -45, -8, -73, 47)#绿色颜色阈值
blue_threshold=(46, 4, 53, -82, -113, -34)#蓝色颜色阈值
#blue_threshold=(29, 49, -50, 25, -63, -35)
red_color_code = 1 # code = 2^0 = 1
green_color_code = 2 # code = 2^1 = 2
blue_color_code = 4 #code=2^2=4
black_color_code = 8 #code=2^3=8
led = pyb.LED(3)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
sensor.set_auto_gain(False) # must turn this off to prevent image washout...
clock = time.clock()
uart = UART(3, 9600, timeout_char = 1000)
uart.init(9600, bits=8, parity=None, stop=1)
c=d=1
while(b2==1):
uart = UART(3, 9600, timeout_char = 1000)
uart.init(9600, bits=8, parity=None, stop=1)
clock.tick()
img = sensor.snapshot()
img.lens_corr(0.8) # strength of 1.8 is good for the 2.8mm lens.
for code in img.find_qrcodes():
data_out = code.payload()
if data_out:
uart.write(data_out)
print(data_out)
b2=2看看接线有没有问题,GND有没有连起来。
@kidswong999 我们后面试出来,是接收端那边的问题,那边输入模式设置错了😂