예제 #1
0
파일: ir_head.py 프로젝트: xuyuan/pyev3
'''use IR sensor as head to focus on beacon
'''

import time
from sensor import IRSeeker
from motor import Motor
from move import MoveTank
import leds
import sound

ir = IRSeeker()
head_motor = Motor('A')
head_motor.position = 0
head_motor.brake_mode = 'off'
head_motor.regulation_mode = 'on'
head_motor.ramp_up = 300
head_motor.ramp_down = 300
head_motor.speed_setpoint = 20

move = MoveTank(0.15)

head_scan_direction = 1
scanning = False
state_changed = False

try:
    while True:
        heading, distance = ir.heading_and_distance
        last_scanning = scanning
        if distance > 0:
            head_motor.run_mode = 'forever'