在openmv中写了一个二维码的代码后,可以直接在此代码的后面写控制舵机的代码吗?
-
请在这里粘贴代码 # Servo Control Example # # This example shows how to use your OpenMV Cam to control servos. import time from pyb import Servo # 二维码例程 # # 这个例子展示了OpenMV Cam使用镜头校正来检测QR码的功能(请参阅qrcodes_with_lens_corr.py脚本以获得更高的性能)。 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() 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) print(clock.fps()) s1 = Servo(1) # P7 s2 = Servo(2) # P8 #s3 = Servo(3) # P9 Only for OpenMV3 M7 if code=="126788" for i in range(-90,90): s1.angle(i) s2.angle(i) time.sleep(10) else for i in range(90,-90): s1.angle(i) s2.angle(i) time.sleep(10)
-
效果当然是可以实现的,你的代码不一定。
你的代码有什么问题?
-
@kidswong999 还没检测,我就是想问一下原理是否可以,谢谢了