Getting Started With ARDUINO UNO With Python Language | All In One Code

Опубликовано: 29 Сентябрь 2024
на канале: AIOC all in one code
43,019
553

Official ARDUINO Site: https://www.arduino.cc/
-------------------- pip install serial -------------------------------

ser = serial.Serial('COM4', 9800, timeout=1)
time.sleep(2)

user_input = 'L'
while user_input != 'q':
user_input = input('H = on, L = off, q = quit' : )
byte_command = encode(user_input)
ser.writelines(byte_command) # send a byte
time.sleep(0.5) # wait 0.5 seconds

print('q entered. Exiting the program')
ser.close()