Thursday, March 21, 2013

Talk with Arduino Due in Python Shell

With pySerial installed, it's easy to communicate with Arduino board in Python Shell.

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:


No comments:

Post a Comment