Código e Implementación » History » Version 20
Version 19 (Cesar Jimenez, 10/13/2023 10:10 AM) → Version 20/41 (Cesar Jimenez, 12/01/2023 08:48 AM)
h1. ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤWikipedia
!logoPRO.png!
----
+*Grupo A:*+
> Integrantes: Cristian Sánchez, Jean Pier Duran, Sergio Rabanal, Valentina Álvarez, César Jiménez
> Nombre del Producto: Machine EV3 G
> Modulo: Proyecto I
> Docente: Humberto Urrutia
> Fecha de Inicio: 2023-08-14
> Fecha de Termino: 2023-11-30
----
*ㅤㅤㅤㅤㅤㅤㅤÍndice:*
* [[Introducción]]
* [[Descripción y Objetivos]]
* [[Organización y Planificación]]
* [[Análisis y Diseño]]
* [[Código e Implementación]]
* [[Bibliografía]]
h1. ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤIntefaz Gráfica
<pre><code class="ruby">
import tkinter as tk
from tkinter import ttk
from tkinter import *
from tkinter import messagebox
from tkinter import PhotoImage socket
# from ev3dev2.motor import socket
conection = False
MediumMotor, LargeMotor, OUTPUT_A, OUTPUT_B, OUTPUT_D, MoveTank
def stop(Event): Shot():
try:
server.send(bytes([ord(' ')])) shot = 'SHOT'
except BrokenPipeError:
messagebox.showwarning("Lo siento","Intentelo Nuevamente")
server.send(shot.encode('utf-8'))
def Shoter(): Movement():
try:
server.send(bytes([ord('r')])) movement = 'MOVEMENT'
except BrokenPipeError:
messagebox.showwarning("Lo siento","Intentelo Nuevamente")
server.send(movement.encode('utf-8'))
def Up():
try:
server.send(bytes([ord('w')])) up = 'UP'
except BrokenPipeError:
messagebox.showwarning("Lo siento","Intentelo Nuevamente") server.send(up.encode('utf-8'))
def Down():
try:
server.send(bytes([ord('s')])) down = 'DOWN'
except BrokenPipeError:
messagebox.showwarning("Lo siento","Intentelo Nuevamente") server.send(down.encode('utf-8'))
def Left():
try:
server.send(bytes([ord('a')])) left = 'LEFT'
except BrokenPipeError:
messagebox.showwarning("Lo siento","Intentelo Nuevamente")
server.send(left.encode('utf-8'))
def Right():
try:
server.send(bytes([ord('d')])) right = 'RIGHT'
except BrokenPipeError:
messagebox.showwarning("Lo siento","Intentelo Nuevamente")
server.send(right.encode('utf-8'))
def Disconnect(): Power():
if conection:
server.send(bytes([ord('z')]))
ventana.destroy() #INSERTAR CAMBIOS / AJUSTES PROGRAMA PRINCIPAL
else:
ventana.destroy()
print()
def Power(Pow): Angle():
if (Pow == 45):
server.send(bytes([ord('1')])) #INSERTAR CAMBIOS / AJUSTE DE ANGULO ?
elif (Pow == 60):
server.send(bytes([ord('2')]))
elif (Pow == 90):
server.send(bytes([ord('2')]))
else:
server.send(bytes([ord('3')])) print()
def conectar():
global server
server = socket.socket()
puerto = 4999
direccion = "192.168.137.147" "192.168.47.61"
try:
server.connect((direccion,puerto))
messagebox.showinfo("Conectado","Se ha establecido la conexion exitosamente")
conection = True
except BrokenPipeError: socket.error:
messagebox.showwarning("Desconectado","Ingrese la dirección correcta")
conection = False
# Ventana principal
server.close()
ventana = tk.Tk()
ventana.geometry("750x500") ventana.geometry("500x400")
ventana.title("Machine EV3")
ventana.configure(bg="light sea green") ventana.configure(bg="cadetblue")
ventana.resizable(0,0)
# Ingresar Imagenes
up = PhotoImage(file="up.png")
down = PhotoImage(file="down.png")
left = PhotoImage(file="left.png")
right = PhotoImage(file="right.png")
cross = PhotoImage(file="cross.png") #Variables
# Dimensiones de las Imagenes
up = up.subsample(6, 6)
down = down.subsample(6, 6)
left = left.subsample(6, 6)
right = right.subsample(6, 6)
cross = cross.subsample(6, 6)
# Iniciar Servidor
server = socket.socket()
# Boton Arriba
boton_arriba = Button(None, repeatdelay=50,repeatinterval=50,text="UP", Button(text="UP", command=Up, background="cadetblue2", image=up)
boton_arriba.place(x=500, y=110)
background="lightblue").place(x=200, y=70, width=120, height=90)
# Boton Derecha Abajo
boton_derech boton_abajo = Button(None, repeatdelay=50,repeatinterval=50 ,text="RIGHT", command=Right, background="cadetblue2", image=right)
boton_derech.place(x=610, y=220) Button(text="DOWN", command=Down, background="lightblue").place(x=200, y=270, width=120, height=90)
# Boton Izquierda
boton_izq = Button(None, repeatdelay=50,repeatinterval=50, text="LEFT", Button(text="LEFT", command=Left, background="cadetblue2", image=left)
boton_izq.place(x=390, y=220) background="lightblue").place(x=50, y=170, width=120, height=90)
# Boton Abajo Derecha
boton_abajo boton_derech = Button(None, repeatdelay=50, repeatinterval=50,text="DOWN", command=Down, background="cadetblue2", image=down)
boton_abajo.place(x=500, y=330) Button(text="RIGHT", command=Right, background="lightblue").place(x=340, y=170, width=120, height=90)
# Boton Disparar
boton_disparar = Button(text="SHOT", command=lambda:[Power(50)], background="cadetblue2", image=cross)
boton_disparar.place(x=130, y=270) Button(text="Shot", command=Shot, background="lightblue").place(x=385, y=345, width=100, height=50)
# Boton Power de 30° 15%
boton_p30 boton_p15 = Button(text="Angle 45%", command=lambda:[Power(45)], background="cadetblue2",fg = "DodgerBlue4")
boton_p30.config(width=9, height=4)
boton_p30.place(x=50, y=230) Button(text="Power 10%", command=Power, background="lightblue").place(x=10, y=20, width=110, height=30)
# Boton Power de 60° 25%
boton_p60 boton_p25 = Button(text="Angle 60%", command=lambda:[Power(60)], background="cadetblue2",fg = "DodgerBlue4")
boton_p60.config(width=9, height=4)
boton_p60.place(x=140, y=170) Button(text="Power 30%", command=Power, background="lightblue").place(x=135, y=20, width=110, height=30)
# Boton potenca de 90° 40%(max)
boton_p100 boton_p40 = Button(text="Angle 90%", command=lambda:[Power(90)], background="cadetblue2",fg = "DodgerBlue4") Button(text="Power 50%", command=Power, background="lightblue").place(x=260, y=20, width=110, height=30)
# Boton Power por tiempo
boton_p100.config(width=9, height=4)
boton_p100.place(x=230, y=230) boton_pseg= Button(text="Power for second.",command=Power, background="lightblue").place(x=385, y=20, width=110, height=30)
# Boton ingreso ip
boton_conectar = Button(text="Conect",background="cadetblue2",fg = "DodgerBlue4",command=conectar)
boton_conectar.config(width=9, height=1)
boton_conectar.place(x=30, y=20) Button(text="Conection at Robot",command= conectar,background="lightblue").place(x=10, y=365, width=130, height=30)
# Desconectar Brick
boton_exit = Button(text="Disconnect",command = Disconnect,background="cadetblue2",fg = "DodgerBlue4")
boton_exit.config(width=9, height=1)
boton_exit.place(x=130, y=20)
# Detener Motores
boton_arriba.bind('<ButtonRelease-1>',stop)
boton_abajo.bind('<ButtonRelease-1>',stop)
boton_izq.bind('<ButtonRelease-1>',stop)
boton_derech.bind('<ButtonRelease-1>',stop)
ventana.mainloop()
</code></pre>
h1. Servidor
<pre><code class="ruby">
import socket
from Funciones import *
# Crear un socket del servreceptor servidor
server = socket.socket()
#192.168.107.147 ip robot
# Vincular el socket a una dirección IP y un puerto
server.bind(('',4999)) # ES LA IP DEL ROBOT
print("CONECTADO") server_address = ("192.168.47.61", 4999)
server.bind(server_address)
# Poner el socket en modo de escucha
server.listen(5) server.listen(1) # Permite hasta 5 conexiones pendientes
print("Esperando conexiones entrantes...")
socket_client, address_client = server.accept()
# Aceptar una conexión entrante
socket_client, address_client = server.accept()
print("Conexion print(f"Conexión entrante desde 192.168.47.147")
{address_client}")
# Recibir datos del cliente
identifier = socket_client.recv(1024).decode('utf-8')
while True:
recept identifier = socket_client.recv(1).recept.decode("utf-8") socket_client.recv(1024).decode('utf-8')
if (recept (identifier == 'w'): # arriba 'UP'):
Mov_Up()
if (recept == 's'): # abajo #AGREGAR FUNCION
Mov_Down() print()
if (recept (identifier == 'a'): # izquierda 'DOWN'):
Mov_Left() #AGREGAR FUNCION
print()
if (recept (identifier == 'd'): # derecha 'LEFT'):
Mov_Right() #AGREGAR FUNCION
print()
if (Id.isdigit()): # disparo por angulo
if (recept (identifier == '1'):
Angle45() 'RIGHT'):
elif (recept == '2'):
Angle60() #AGREGAR FUNCION
elif (recept print()
if(identifier == '3'):
Angle90()
if (recept == 'z'): # Cierre Ventana 'CERRAR'):
#AGREGAR FUNCION
break print()
socket_client.close()
if (recept == ' '): # Detener Movimiento
Stop_Motor() server.close()
</code></pre>
h1. Funciones Principales del Robot
<pre><code class="ruby">
from ev3dev.ev3 import Sound
from ev3dev2.motor import LargeMotor,OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D, MoveTank
from time import sleep
import time
#Agregar Funciones del ROBOT
rueda_left = LargeMotor(OUTPUT_C)
rueda_right = LargeMotor(OUTPUT_B)
motor_A = LargeMotor(OUTPUT_A)
def Mov_Right():
motor_A.run_forever(speed_sp=80)
def Mov_Left(): mover_Der = MoveTank(OUTPUT_C, OUTPUT_B)
motor_A.run_forever(speed_sp=-80)
def Mov_Down(): mover_Der.on_for_seconds(100,-100,1, brake = False, block = True)
rueda_left.run_forever(speed_sp=500)
rueda_right.run_forever(speed_sp=500) # 100 velocidad de primer motor , -100 velocidad del segundo motor declarado, 1 es el tiempo del proceso
print()
def Mov_Up(): Mov_Left():
rueda_left.run_forever(speed_sp=-500) mover_Izq = MoveTank(OUTPUT_C, OUTPUT_B)
rueda_right.run_forever(speed_sp=-500)
def Stop_Motor(): mover_Izq.on_for_seconds(-100,100,1,brake = False, block= True)
rueda_left.stop()
rueda_right.stop()
motor_A.stop() print()
def Angle45(): Mov_Down():
motor_D Ruedas_Down = LargeMotor(OUTPUT_D) MoveTank(OUTPUT_B,OUTPUT_C)
motor_D.on_for_degrees(speed=10, degrees = 45) Ruedas_Down.on_for_seconds(100,100,1,brake= False, block=True)
motor_D.on_for_degrees(speed=100, degrees = -105)
motor_D.on_for_degrees(speed=10, degrees = 60)
motor_D.off()
print()
def Angle60(): Mov_Up():
motor_D #motor A y D
RuedasB_C = LargeMotor(OUTPUT_D) MoveTank(OUTPUT_B,OUTPUT_C)
motor_D.on_for_degrees(speed=10, degrees = 60) RuedasB_C.on_for_seconds(-100,-100,1, brake=False, block=True)
motor_D.on_for_degrees(speed=100, degrees = -120)
motor_D.on_for_degrees(speed=10, degrees = 60)
motor_D.off() #rotacion al 50% de la velocidad maxima
def Angle90(): Mov_Lever():
motor_D motor_A = LargeMotor(OUTPUT_D) LargeMotor(OUTPUT_A)
motor_D.on_for_degrees(speed=10, degrees = 90) motor_A.on_for_seconds(speed=50, seconds=2)
motor_D.on_for_degrees(speed=100, degrees = -150)
motor_D.on_for_degrees(speed=10, degrees = 60)
motor_D.off()
motor_A.off()
def Sonido():
# Inicializa el altavoz
sound = Sound()
# Reproduce un sonido
sound.beep()
# Reproduce un mensaje de voz
sound.speak("Vini o' rey do futebol")
</code></pre>
!logoPRO.png!
----
+*Grupo A:*+
> Integrantes: Cristian Sánchez, Jean Pier Duran, Sergio Rabanal, Valentina Álvarez, César Jiménez
> Nombre del Producto: Machine EV3 G
> Modulo: Proyecto I
> Docente: Humberto Urrutia
> Fecha de Inicio: 2023-08-14
> Fecha de Termino: 2023-11-30
----
*ㅤㅤㅤㅤㅤㅤㅤÍndice:*
* [[Introducción]]
* [[Descripción y Objetivos]]
* [[Organización y Planificación]]
* [[Análisis y Diseño]]
* [[Código e Implementación]]
* [[Bibliografía]]
h1. ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤIntefaz Gráfica
<pre><code class="ruby">
import tkinter as tk
from tkinter import ttk
from tkinter import *
from tkinter import messagebox
from tkinter import PhotoImage socket
# from ev3dev2.motor import socket
conection = False
MediumMotor, LargeMotor, OUTPUT_A, OUTPUT_B, OUTPUT_D, MoveTank
def stop(Event): Shot():
try:
server.send(bytes([ord(' ')])) shot = 'SHOT'
except BrokenPipeError:
messagebox.showwarning("Lo siento","Intentelo Nuevamente")
server.send(shot.encode('utf-8'))
def Shoter(): Movement():
try:
server.send(bytes([ord('r')])) movement = 'MOVEMENT'
except BrokenPipeError:
messagebox.showwarning("Lo siento","Intentelo Nuevamente")
server.send(movement.encode('utf-8'))
def Up():
try:
server.send(bytes([ord('w')])) up = 'UP'
except BrokenPipeError:
messagebox.showwarning("Lo siento","Intentelo Nuevamente") server.send(up.encode('utf-8'))
def Down():
try:
server.send(bytes([ord('s')])) down = 'DOWN'
except BrokenPipeError:
messagebox.showwarning("Lo siento","Intentelo Nuevamente") server.send(down.encode('utf-8'))
def Left():
try:
server.send(bytes([ord('a')])) left = 'LEFT'
except BrokenPipeError:
messagebox.showwarning("Lo siento","Intentelo Nuevamente")
server.send(left.encode('utf-8'))
def Right():
try:
server.send(bytes([ord('d')])) right = 'RIGHT'
except BrokenPipeError:
messagebox.showwarning("Lo siento","Intentelo Nuevamente")
server.send(right.encode('utf-8'))
def Disconnect(): Power():
if conection:
server.send(bytes([ord('z')]))
ventana.destroy() #INSERTAR CAMBIOS / AJUSTES PROGRAMA PRINCIPAL
else:
ventana.destroy()
print()
def Power(Pow): Angle():
if (Pow == 45):
server.send(bytes([ord('1')])) #INSERTAR CAMBIOS / AJUSTE DE ANGULO ?
elif (Pow == 60):
server.send(bytes([ord('2')]))
elif (Pow == 90):
server.send(bytes([ord('2')]))
else:
server.send(bytes([ord('3')])) print()
def conectar():
global server
server = socket.socket()
puerto = 4999
direccion = "192.168.137.147" "192.168.47.61"
try:
server.connect((direccion,puerto))
messagebox.showinfo("Conectado","Se ha establecido la conexion exitosamente")
conection = True
except BrokenPipeError: socket.error:
messagebox.showwarning("Desconectado","Ingrese la dirección correcta")
conection = False
# Ventana principal
server.close()
ventana = tk.Tk()
ventana.geometry("750x500") ventana.geometry("500x400")
ventana.title("Machine EV3")
ventana.configure(bg="light sea green") ventana.configure(bg="cadetblue")
ventana.resizable(0,0)
# Ingresar Imagenes
up = PhotoImage(file="up.png")
down = PhotoImage(file="down.png")
left = PhotoImage(file="left.png")
right = PhotoImage(file="right.png")
cross = PhotoImage(file="cross.png") #Variables
# Dimensiones de las Imagenes
up = up.subsample(6, 6)
down = down.subsample(6, 6)
left = left.subsample(6, 6)
right = right.subsample(6, 6)
cross = cross.subsample(6, 6)
# Iniciar Servidor
server = socket.socket()
# Boton Arriba
boton_arriba = Button(None, repeatdelay=50,repeatinterval=50,text="UP", Button(text="UP", command=Up, background="cadetblue2", image=up)
boton_arriba.place(x=500, y=110)
background="lightblue").place(x=200, y=70, width=120, height=90)
# Boton Derecha Abajo
boton_derech boton_abajo = Button(None, repeatdelay=50,repeatinterval=50 ,text="RIGHT", command=Right, background="cadetblue2", image=right)
boton_derech.place(x=610, y=220) Button(text="DOWN", command=Down, background="lightblue").place(x=200, y=270, width=120, height=90)
# Boton Izquierda
boton_izq = Button(None, repeatdelay=50,repeatinterval=50, text="LEFT", Button(text="LEFT", command=Left, background="cadetblue2", image=left)
boton_izq.place(x=390, y=220) background="lightblue").place(x=50, y=170, width=120, height=90)
# Boton Abajo Derecha
boton_abajo boton_derech = Button(None, repeatdelay=50, repeatinterval=50,text="DOWN", command=Down, background="cadetblue2", image=down)
boton_abajo.place(x=500, y=330) Button(text="RIGHT", command=Right, background="lightblue").place(x=340, y=170, width=120, height=90)
# Boton Disparar
boton_disparar = Button(text="SHOT", command=lambda:[Power(50)], background="cadetblue2", image=cross)
boton_disparar.place(x=130, y=270) Button(text="Shot", command=Shot, background="lightblue").place(x=385, y=345, width=100, height=50)
# Boton Power de 30° 15%
boton_p30 boton_p15 = Button(text="Angle 45%", command=lambda:[Power(45)], background="cadetblue2",fg = "DodgerBlue4")
boton_p30.config(width=9, height=4)
boton_p30.place(x=50, y=230) Button(text="Power 10%", command=Power, background="lightblue").place(x=10, y=20, width=110, height=30)
# Boton Power de 60° 25%
boton_p60 boton_p25 = Button(text="Angle 60%", command=lambda:[Power(60)], background="cadetblue2",fg = "DodgerBlue4")
boton_p60.config(width=9, height=4)
boton_p60.place(x=140, y=170) Button(text="Power 30%", command=Power, background="lightblue").place(x=135, y=20, width=110, height=30)
# Boton potenca de 90° 40%(max)
boton_p100 boton_p40 = Button(text="Angle 90%", command=lambda:[Power(90)], background="cadetblue2",fg = "DodgerBlue4") Button(text="Power 50%", command=Power, background="lightblue").place(x=260, y=20, width=110, height=30)
# Boton Power por tiempo
boton_p100.config(width=9, height=4)
boton_p100.place(x=230, y=230) boton_pseg= Button(text="Power for second.",command=Power, background="lightblue").place(x=385, y=20, width=110, height=30)
# Boton ingreso ip
boton_conectar = Button(text="Conect",background="cadetblue2",fg = "DodgerBlue4",command=conectar)
boton_conectar.config(width=9, height=1)
boton_conectar.place(x=30, y=20) Button(text="Conection at Robot",command= conectar,background="lightblue").place(x=10, y=365, width=130, height=30)
# Desconectar Brick
boton_exit = Button(text="Disconnect",command = Disconnect,background="cadetblue2",fg = "DodgerBlue4")
boton_exit.config(width=9, height=1)
boton_exit.place(x=130, y=20)
# Detener Motores
boton_arriba.bind('<ButtonRelease-1>',stop)
boton_abajo.bind('<ButtonRelease-1>',stop)
boton_izq.bind('<ButtonRelease-1>',stop)
boton_derech.bind('<ButtonRelease-1>',stop)
ventana.mainloop()
</code></pre>
h1. Servidor
<pre><code class="ruby">
import socket
from Funciones import *
# Crear un socket del servreceptor servidor
server = socket.socket()
#192.168.107.147 ip robot
# Vincular el socket a una dirección IP y un puerto
server.bind(('',4999)) # ES LA IP DEL ROBOT
print("CONECTADO") server_address = ("192.168.47.61", 4999)
server.bind(server_address)
# Poner el socket en modo de escucha
server.listen(5) server.listen(1) # Permite hasta 5 conexiones pendientes
print("Esperando conexiones entrantes...")
socket_client, address_client = server.accept()
# Aceptar una conexión entrante
socket_client, address_client = server.accept()
print("Conexion print(f"Conexión entrante desde 192.168.47.147")
{address_client}")
# Recibir datos del cliente
identifier = socket_client.recv(1024).decode('utf-8')
while True:
recept identifier = socket_client.recv(1).recept.decode("utf-8") socket_client.recv(1024).decode('utf-8')
if (recept (identifier == 'w'): # arriba 'UP'):
Mov_Up()
if (recept == 's'): # abajo #AGREGAR FUNCION
Mov_Down() print()
if (recept (identifier == 'a'): # izquierda 'DOWN'):
Mov_Left() #AGREGAR FUNCION
print()
if (recept (identifier == 'd'): # derecha 'LEFT'):
Mov_Right() #AGREGAR FUNCION
print()
if (Id.isdigit()): # disparo por angulo
if (recept (identifier == '1'):
Angle45() 'RIGHT'):
elif (recept == '2'):
Angle60() #AGREGAR FUNCION
elif (recept print()
if(identifier == '3'):
Angle90()
if (recept == 'z'): # Cierre Ventana 'CERRAR'):
#AGREGAR FUNCION
break print()
socket_client.close()
if (recept == ' '): # Detener Movimiento
Stop_Motor() server.close()
</code></pre>
h1. Funciones Principales del Robot
<pre><code class="ruby">
from ev3dev.ev3 import Sound
from ev3dev2.motor import LargeMotor,OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D, MoveTank
from time import sleep
import time
#Agregar Funciones del ROBOT
rueda_left = LargeMotor(OUTPUT_C)
rueda_right = LargeMotor(OUTPUT_B)
motor_A = LargeMotor(OUTPUT_A)
def Mov_Right():
motor_A.run_forever(speed_sp=80)
def Mov_Left(): mover_Der = MoveTank(OUTPUT_C, OUTPUT_B)
motor_A.run_forever(speed_sp=-80)
def Mov_Down(): mover_Der.on_for_seconds(100,-100,1, brake = False, block = True)
rueda_left.run_forever(speed_sp=500)
rueda_right.run_forever(speed_sp=500) # 100 velocidad de primer motor , -100 velocidad del segundo motor declarado, 1 es el tiempo del proceso
print()
def Mov_Up(): Mov_Left():
rueda_left.run_forever(speed_sp=-500) mover_Izq = MoveTank(OUTPUT_C, OUTPUT_B)
rueda_right.run_forever(speed_sp=-500)
def Stop_Motor(): mover_Izq.on_for_seconds(-100,100,1,brake = False, block= True)
rueda_left.stop()
rueda_right.stop()
motor_A.stop() print()
def Angle45(): Mov_Down():
motor_D Ruedas_Down = LargeMotor(OUTPUT_D) MoveTank(OUTPUT_B,OUTPUT_C)
motor_D.on_for_degrees(speed=10, degrees = 45) Ruedas_Down.on_for_seconds(100,100,1,brake= False, block=True)
motor_D.on_for_degrees(speed=100, degrees = -105)
motor_D.on_for_degrees(speed=10, degrees = 60)
motor_D.off()
print()
def Angle60(): Mov_Up():
motor_D #motor A y D
RuedasB_C = LargeMotor(OUTPUT_D) MoveTank(OUTPUT_B,OUTPUT_C)
motor_D.on_for_degrees(speed=10, degrees = 60) RuedasB_C.on_for_seconds(-100,-100,1, brake=False, block=True)
motor_D.on_for_degrees(speed=100, degrees = -120)
motor_D.on_for_degrees(speed=10, degrees = 60)
motor_D.off() #rotacion al 50% de la velocidad maxima
def Angle90(): Mov_Lever():
motor_D motor_A = LargeMotor(OUTPUT_D) LargeMotor(OUTPUT_A)
motor_D.on_for_degrees(speed=10, degrees = 90) motor_A.on_for_seconds(speed=50, seconds=2)
motor_D.on_for_degrees(speed=100, degrees = -150)
motor_D.on_for_degrees(speed=10, degrees = 60)
motor_D.off()
motor_A.off()
def Sonido():
# Inicializa el altavoz
sound = Sound()
# Reproduce un sonido
sound.beep()
# Reproduce un mensaje de voz
sound.speak("Vini o' rey do futebol")
</code></pre>