I have a question about the servos. As soon as I initialize the servos, they start putting out a signal and I don’t see how to disable them or put them in a known state. What I am trying to do is to activate the servos only when color red is detected. Here is the code. Any assistant will be much appreciated.
import sensor, image, time
from pyb import LED, Pin, Servo
#from move import forward, reverse, spin
red_led = LED(1)
#rtwheel = Servo(1) # P7
#ltwheel = Servo(2) # P8
#rtwheel.angle(45) # move servo 1 to 45 degrees
#rtwheel.angle(0) # move servo 2 to 0 degrees
ExtRedLEDOn = Pin('P0', Pin.OUT_PP, Pin.PULL_NONE)
ExtRedLEDOff = Pin('P0', Pin.OUT_PP, Pin.PULL_NONE)
red = ( 40, 60, 60, 90, 50, 70)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(10)
sensor.set_whitebal(False)
clock = time.clock()
red_led.off()
ExtRedLEDOn.low()
while(True):
clock.tick()
img = sensor.snapshot()
blobs = img.find_blobs([red])
if blobs:
red_led.on()
ExtRedLEDOn.high()
for b in blobs:
img.draw_rectangle(b[0:4])
img.draw_cross(b[5], b[6])
#time.sleep(50)
# move servo1 and servo2 synchronously, taking 1500ms
rtwheel.angle(-60, 1500)
rtwheel.angle(30, 1500)
red_led.off()
ExtRedLEDOn.low()