Connect Arduino Due with sketch of former post downloaded.
For Python 2.x, enter the commands in Python Shell to turn ON/OFF LED on Arduino Due Board
>>>import serial
>>>ser = serial.Serial('/dev/ttyACM0', 115200)
>>>ser.write('H')
>>>ser.write('L')
For Python 3.x, the String in write() have to be casted to bytes.
>>>import serial
>>>ser = serial.Serial('/dev/ttyACM0', 115200)
>>>ser.write(bytes('H', 'UTF-8'))
>>>ser.write(bytes('L', 'UTF-8'))
Related:
- serial.serialutil.SerialException: could not open port /dev/ttyACM0
- Communicate with Arduino in Python programmatically
No comments:
Post a Comment