Python + Arduino with Mac OS X
The easiest way to communicate in Python with the Arduino (or any microcontroller with serial) is using pySerial.
Here's an example:
import serial
s = serial.Serial(port='/dev/tty.usbmodemfa141', baudrate=9600)
s.write('text')
s.read()
s.readline()
PS: If you're using Python 3, you should send bytes instead of strings (that is, b'text'
).