from ev3dev2.motor import LargeMotor, MediumMotor, OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D, SpeedPercent, MoveTank
from ev3dev2.sensor import INPUT_1
from ev3dev2.sensor .lego import UltrasonicSensor
from ev3dev2.sound import Sound
from ev3dev2.led import Leds
motor_angle= LargeMotor(OUTPUT_A)
cannon = MediumMotor(OUTPUT_D)
sonido = Sound()
sensor = UltrasonicSensor(INPUT_1)
sensor.mode = "US-DIST-CM"
tankmoves = MoveTank(OUTPUT_B,OUTPUT_C)
print(sensor.value()/10)
def moveUp():
print("Moving up...")
tankmoves.on(SpeedPercent(100),SpeedPercent(100))
def moveDown():
print("Moving down...")
tankmoves.on(SpeedPercent(-100),SpeedPercent(-100))
def moveRight():
print("Moving right...")
tankmoves.on(SpeedPercent(100),SpeedPercent(-100))
def moveLeft():
print("Moving left...")
tankmoves.on(SpeedPercent(-100),SpeedPercent(100))
def Inclinacion0():
motor_angle.on_for_degrees(7,55,brake=True)
def Inclinacion45():
motor_angle.on_for_degrees(7,-55,brake=True)
def Disparar():
cannon.on(SpeedPercent(-100))
def Apuntar():
sensor.value
def Luciano():
sonido.speak("gorila tank mak two")
def Distancia():
while(sensor.value()/10 <= 100 or sensor.value()/10 >= 110):
print(sensor.value()/10)
if(sensor.value()/10 < 100):
tankmoves.on(SpeedPercent(-40),SpeedPercent(-40))
else:
tankmoves.on(SpeedPercent(40),SpeedPercent(40))
Stop()
def Stop():
tankmoves.stop()
def StopCannon():
cannon.stop()
sonido.play_file("misioncumplida.wav",100,1)