Advertisement
tomateblue

BigRobot.py

Mar 3rd, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. import serial
  2. import psutil
  3.  
  4. try:
  5.   arduino = serial.Serial("/dev/ttyUSB0",9600)
  6. except:
  7.   arduino = serial.Serial("/dev/ttyACM0",9600)
  8.   try:
  9.     arduino = serial.Serial("/dev/ttyACM1",9600)
  10.   except:
  11.     arduino = ""
  12.  
  13. class Move:
  14.   def __init__(self,direcao):
  15.    self.direcao = direcao
  16.   def mover(self):
  17.    if self.direcao == 'w':
  18.       print "w -  FRENTE"
  19.       arduino.write('w')
  20.  
  21.    if self.direcao == "s":
  22.       print "s - RE"
  23.       arduino.write('s')
  24.  
  25.    if self.direcao == "a":
  26.       print "a - ESQUERDA"
  27.       arduino.write('a')
  28.  
  29.    if self.direcao == "d":
  30.       print "d - direita "
  31.       arduino.write('d')
  32.  
  33.    if self.direcao == "p":
  34.       print "p - stop"
  35.       arduino.write('p')
  36.  
  37. class Sensores:
  38.   def __init__(self,distancia, bateria):
  39.     self.distancia = distancia
  40.     self.bateria = bateria
  41.  
  42.   def bat(self):
  43.    if self.bateria == True:
  44.      bat = psutil.sensors_battery()[0]
  45.      print   bat
  46.    else: print "FAIL BAT"
  47.  
  48.   def distance(self):
  49.      pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement