from pyb import Servo
import time
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) # 必须关闭此功能,以防止图像冲洗…
clock = time.clock()
while(True):
clock.tick()
img = sensor.snapshot()
img.lens_corr(1.8) # 1.8的强度参数对于2.8mm镜头来说是不错的。
for code in img.find_qrcodes():
img.draw_rectangle(code.rect(), color = (255, 0, 0))
message = code.payload()
print(message)
print(clock.fps())
s1 = Servo(1) # servo on position 1 (P7)
while(1):
if str((payload()) = 'shanghai'
s1.angle(90) # move to 45 degrees
time.sleep_ms(600)
s1.angle(45) # move to -60 degrees in 1500ms
time.sleep_ms(600)
s1.angle(0) # move to 45 degrees
time.sleep_ms(600)
s1.angle(-45) # move to -60 degrees in 1500ms
time.sleep_ms(600)
s1.angle(-60) # move to 45 degrees
time.sleep_ms(600)
s1.angle(-90) # move to -60 degrees in 1500ms
time.sleep_ms(600)
#s1.speed(25) # for continuous rotation servos
1
1r3n 发布的帖子
-
openmv进行扫码检测然后在将检测的结果进行对比然后控制舵机为什么显示语法错误啊就比如这段代码 如果检测结果为上海舵机