Advertisement
pkaislan

codepython

May 12th, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. # Imports
  2. import time
  3. import serial
  4.  
  5. if __name__ == '__main__':
  6.  
  7.  t=str(chr(116))
  8.  u=str(chr(117))
  9.  retonar=str(chr(0))
  10.  
  11.  print ("Obtendo informacoes da Conexao com o Arduino\n")
  12.  conectar = serial.Serial('COM3', 9600, timeout=1)
  13.  retonar=conectar.readline()
  14.  print ("Conexao Estabelecida com Sucesso!")
  15.  print ("Status da Porta: %s", conectar.isOpen())
  16.  print ("Arduino conectado: %s", conectar.name)
  17.  print ("Dump da configuracao: %s", conectar)
  18.  time.sleep(2)
  19.  conectar.write(b't')
  20.  time.sleep(1.5)
  21.  retornar= conectar.read(1)
  22.  if (retornar == 1):
  23.      print("Teste")
  24.  else:
  25.      print("Nao a Resposta!")
  26.  time.sleep(10)
  27.  conectar.write(b'u')
  28.  time.sleep(1.5)
  29.  if (retornar == 1):
  30.      print("Teste!")
  31.  else:
  32.      print("Nao a resposta!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement