Entweder stell ich mich zu doof an oder ich weiß auch nicht..
Ich möchte gern per Python hexzahlen an den Arduino senden und dadurch LEDS aufleuchten lassen.
Verstehe nicht warum das Ganze nicht funktioniert - hier mein Code:
Von Python ans Arduino:
import serial
import time
ser = serial.Serial('COM3', 9600)
time.sleep(2)
ser.write(0x1B)
if not ser.isOpen():
ser.open()
print('com3 is open', ser.isOpen())
Bitte in English.. Von python kannst du nicht sicher sein das nur 1 byte mit serial.write(..) gesendet wird. Bitte versuche mit "serial.write(chr(0x1B))".
You cannot be sure that serial.write in python only writes one byte. 0x1B may be a 4 byte (32 bit) data type. You need to specifically tell python only to transmit one byte with something like "serial.write(chr(0x1B))". You can check the return value of "serial.write()" to see how many bytes are send from python.
EDIT: Oh.. And you should probably make sure that serial is opened in python before sending anything
Just change it to "ser.write(chr('\x1B'))" as suggested - and remember to open the serial connection before writing to it, looks like you are writing to it before opening it