import serial import time conexao = serial.Serial('COM4', 9600) # Configuração da conexão def pisca(tempo=0.3): while True: conexao.write('1'.encode()) # Escreve 1 no arduino (LED acende) time.sleep(tempo) # Aguarda n segundos conexao.write('2'.encode()) # Escreve 2 no arduino (LED apaga) time.sleep(tempo) # Aguarda n segundos if __name__ == '__main__': # Executa a função pisca()