Diferencia entre revisiones de «Ejemplos»
De Proyecto Butiá
					
										
					
					 (Página creada con 'import butiaAPI import time  robot = butiaAPI.robot()  robot.abrirSensor() robot.abrirMotores()  i = 0 veces = 1 gireDerecha = 0  while i<200:         i += 1         linea = rob...')  | 
				|||
| Línea 1: | Línea 1: | ||
| + | |||
| + | == Texto de titular ==  | ||
| + | <syntaxhighlight lang="python">  | ||
import butiaAPI  | import butiaAPI  | ||
import time  | import time  | ||
| Línea 39: | Línea 42: | ||
robot.setVelocidadMotores("0", "0", "0", "0")  | robot.setVelocidadMotores("0", "0", "0", "0")  | ||
| + | </syntaxhighlight>  | ||
Revisión del 00:17 20 jun 2011
Texto de titular
import butiaAPI
import time
robot = butiaAPI.robot()
robot.abrirSensor()
robot.abrirMotores()
i = 0
veces = 1
gireDerecha = 0
while i<200:
        i += 1
        linea = robot.getEscalaGris()
        print linea
        if linea > "200":
                veces = 1
                robot.setVelocidadMotores("0", "400", "0", "400")
        else:
                if gireDerecha == 1:
                        #Giro a la izq
                        robot.setVelocidadMotores("1", "400", "0", "400")
                        gireDerecha = 0
                else:
                        #Giro a la der
                        robot.setVelocidadMotores("0", "400", "1", "400")
                        gireDerecha = 1
                
                time.sleep(veces * 0.1)
                robot.setVelocidadMotores("0", "0", "0", "0")
                veces += 1
        time.sleep(0.2)
robot.setVelocidadMotores("0", "0", "0", "0")