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:


Comments

Popular posts from this blog

Read analog input of Arduino Due board

Application Note of Cortex-M3 Embedded Software Development