Ejemplo n.º 1
0
from ev3dev.auto import OUTPUT_A, OUTPUT_B, OUTPUT_D, LargeMotor, MediumMotor
from ev3dev.auto import INPUT_1, INPUT_2, ColorSensor, UltrasonicSensor
import time
import ev3dev.ev3 as ev3

#ultrasonicSensor = UltrasonicSensor(INPUT_1)
#colorSensor = ColorSensor(INPUT_2)
clawMotor = MediumMotor(OUTPUT_B)
leftTire = LargeMotor(OUTPUT_A) and LargeMotor(OUTPUT_D)
#rightTire = LargeMotor(OUTPUT_D)

# def getUltrasonic():
#     ultrasonicSensor.mode='US-DIS-CM'
#     return ultrasonicSensor.units
#
# def getColor():
#     colorSensor.mode='COL-REFLECT'
#     return colorSensor.value()
#
#
# #def findObject():
# while getUltrasonic > 5.5:

leftTire.run_timed(speed_sp=360, time_sp=600)
#rightTire.run_timed(speed_sp = 360, time_sp = 600)
time.sleep(1)
leftTire.run_timed(speed_sp=360, time_sp=600)
#rightTire.run_timed(speed_sp = 360, time_sp = 600)
time.sleep(1)
leftTire.run_timed(speed_sp=360, time_sp=600)
#rightTire.run_timed(speed_sp = 360, time_sp = 600)
Ejemplo n.º 2
0
from ev3dev.auto import OUTPUT_D, LargeMotor, OUTPUT_A, MediumMotor, OUTPUT_C
import time

mup = LargeMotor(OUTPUT_D)
mgrab = MediumMotor(OUTPUT_A)
mright = LargeMotor(OUTPUT_C)

#move the arm down
mup.run_timed(speed_sp=360, time_sp=600)
#grab the object
time.sleep(1)
mgrab.run_timed(speed_sp=720, time_sp=500)
# move arm back up
time.sleep(1)
mup.run_timed(speed_sp=-360, time_sp=600)
#move arm right
time.sleep(1)
mright.run_timed(speed_sp=360, time_sp=600)
#move arm down at target location
time.sleep(1)
mup.run_timed(speed_sp=360, time_sp=705)
#release the object
time.sleep(1)
mgrab.run_timed(speed_sp=-360, time_sp=400)
#reset position
time.sleep(1)
mup.run_timed(speed_sp=-360, time_sp=600)
time.sleep(1)
mright.run_timed(speed_sp=-360, time_sp=400)
Ejemplo n.º 3
0
from ev3dev.auto import OUTPUT_A, OUTPUT_B, OUTPUT_D, LargeMotor, MediumMotor
from ev3dev.auto import INPUT_1, INPUT_2, ColorSensor, UltrasonicSensor
import time
import ev3dev.ev3 as ev3

ultrasonicSensor = UltrasonicSensor(INPUT_1)
colorSensor = ColorSensor(INPUT_2)
clawMotor = MediumMotor(OUTPUT_B)
leftTire = LargeMotor(OUTPUT_A)
rightTire = LargeMotor(OUTPUT_D)


def getUltrasonic():
    ultrasonicSensor.mode = 'US-DIS-CM'
    return ultrasonicSensor.units


def getColor():
    colorSensor.mode = 'COL-REFLECT'
    return colorSensor.value()


#def findObject():
while getUltrasonic > 5.5:
    leftTire.run_timed(power=15, rotations=0.2)
    rightTire.run_timed(power=15, rotations=0.2)
    time.sleep(1)
clawMotor.run_timed(power=75, rotations=0.8)
time.sleep(1)

#def findTarget():
Ejemplo n.º 4
0
from ev3dev.auto import OUTPUT_A, OUTPUT_B, OUTPUT_D, LargeMotor, MediumMotor, InfraredSensor
from ev3dev.auto import INPUT_1, INPUT_2, ColorSensor, UltrasonicSensor
import time
import ev3dev.auto as auto
import ev3dev.ev3 as ev3

uss = UltrasonicSensor(INPUT_1)
colorSensor = ColorSensor(INPUT_2)
clawMotor = MediumMotor(OUTPUT_B)
leftTire = LargeMotor(OUTPUT_A)# and LargeMotor(OUTPUT_D)
rightTire = LargeMotor(OUTPUT_D)

ev3.Sound.speak('Ha Ha Ha this is mine now').wait()

leftTire.run_timed(speed_sp = 900, time_sp = 600)
rightTire.run_timed(speed_sp = 900, time_sp = 600)
Ejemplo n.º 5
0
from ev3dev.auto import OUTPUT_A, OUTPUT_B, OUTPUT_C, LargeMotor, MediumMotor
from ev3dev.auto import INPUT_1, INPUT_2, INPUT_3, TouchSensor, ColorSensor
import time
import ev3dev.ev3 as ev3

baseTouch = TouchSensor(INPUT_1)
armTouch = TouchSensor(INPUT_2)
colorSensor = ColorSensor(INPUT_3)
clawMotor = MediumMotor(OUTPUT_A)
armMotor = LargeMotor(OUTPUT_B)
baseMotor = LargeMotor(OUTPUT_C)

# Claw Opening
ev3.Sound.speak("Now opening claw.").wait()
clawMotor.run_forever(speed_sp=100)
time.sleep(.5)
clawMotor.stop()

# Arm Moving to down position
ev3.Sound.speak("Now moving arm down.").wait()
armMotor.run_forever(speed_sp=120)
time.sleep(2.5)
armMotor.stop()

# Claw closing on object to pick up
ev3.Sound.speak("Now closing claw.").wait()
clawMotor.run_forever(speed_sp=-100)
time.sleep(2)

# Arm moving to the up position
ev3.Sound.speak("Now moving arm up.").wait()