为啥这个程序不能重复扫二维码分别控制舵机转?而且识别完二维码后控制的舵机一直转不会停,怎样让它转完就停?
-
为啥这个程序不能重复扫二维码分别控制舵机转?而且识别完二维码后控制的舵机一直转不会停,怎样让它转完就停?
# Untitled - By: 15839 - 周三 5月 10 2023 from pyb import Servo import sensor, image, time 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() s1 = Servo(1) s2 = Servo(2) while(True): clock.tick() 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(): img.draw_rectangle(code.rect(), color = (255, 0, 0)) print(code.payload()) if code.payload()=="1": for i in range(-90,90): time.sleep(2) s1.angle(i) time.sleep(2) s1.angle(-i) if code.payload()=="2": for i in range(-90,90): time.sleep(2) s2.angle(i) time.sleep(2) s2.angle(-i)
-
我听不懂你的逻辑。你可以参考一下云台的代码:https://singtown.com/learn/49603/