예제 #1
0
    def motion_detected(active_sensor):
        motion_angle = GPIO_sensor[active_sensor]
        while True:

            bearing_angle = get_bearing()
            difference = abs(bearing_angle - motion_angle)

            if difference < 10:
                stop()
                print "turned to {}".format(bearing_angle)
                time.sleep(3)
                break
            elif bearing_angle > motion_angle:
                # Motion is anti-clockwise of bearing.
                if bearing_angle - motion_angle < 180:
                    turn_c_clockwise()
                else:
                    turn_clockwise()
            else:
                # Motion is clockwise of bearing.
                if motion_angle - bearing_angle < 180:
                    turn_clockwise()
                else:
                    turn_c_clockwise()
예제 #2
0
 def calibrate(sensor):
     raw_input("turn to face {} and then press enter".format(sensor))
     return get_bearing()