Servidor¶
#!/usr/bin/env pybricks-micropython
import socket
from library import *
s = socket.socket()
print("Socket creado")
port = 19999
s.bind( ("", port) )
print("El socket se creo con puerto:{}".format(port))
s.listen(5)
print("EL socket is listening....")
connect, addr = s.accept()
print("Se conecto a {}".format(addr))
while True:
rawByte = connect.recv(1)
char = rawByte.decode('utf-8')
if (char == 'w'):
avanzar()
if (char == 's'):
retroceder()
if (char == 'd'):
rotarDerecha()
if (char == 'a'):
rotarIzquierda()
if (char == 'p'):
golpeSuave()
if (char == 'f'):
golpeFuerte()
if (char == 'i'):
devolverBrazo()
if (char == ' '):
detener()
detenerBrazo()