1

Estou tentando comunicar um código python e o arduino, porém ele não esta retornando o valor para acender o LED.

Já esta tudo configurado, pip, pyserial etc.

import serial
import time
import os
conexao = serial.Serial('COM3', 9600)

def menu():
    os.system('cls') or None

     print("""
       CONTROLE DO LED
        1- ON
        2- OFF    

          """)
   op = int(input("OPTION: "))

   if op == 1:
      try:
           conexao.write(1)
           print("LED LIGADO")
           time.sleep(1)
           print("RETORNANDO AO MENU")
           time.sleep(1)
           return menu()

      except:
           print("HOUVE ALGUM ERRO")
           print("RETORNANOD AO MENU")
           time.sleep(2)
           return menu()


   if op == 2:
       try:    
           conexao.write(2)
           print("LED DESLIGADO")
           time.sleep(1)
           print("RETORNANDO AO MENU")
           return menu()

       except: 
           print("HOUVE ALGUM ERRO")
           print("RETORNANOD AO MENU")
           time.sleep(2)
           return menu()

 menu()
1
  • Como assim? Não ficou claro, dá algum erro? Ele chega a imprimir a mensagem "HOUVE ALGUM ERRO" ou simplesmente não faz nada? Edite a pergunta e adicione essas informações.
    – nosklo
    18/04/2019 às 20:52

0

Você deve fazer log-in para responder a esta pergunta.

Pesquise outras perguntas com a tag .