Learning About Arduino and Python
Python + Firmata Install
- Install Python dependencies:
$ easy_install pyserial
# e.g.
$ wget http://download.github.com/lupeke-python-firmata-17a02bf211f16f93a0bcf9498dcfd0298c7c82ed.tar.gz
- Unarchive it and change into the directory, then:
python setup.py install
$ python
Python 2.5.1 (r251:54863, Feb 6 2009, 19:02:12)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import firmata
>>> firmata.VERSION
'0.3'
>>>>
- You need to upload the Firmata sketch from File > Examples > Firmata > StandardFirmata to your Arduino.
>>> from firmata import *
>>> a = Arduino('/dev/tty.usbserial-XXXXXXXXXX', baudrate=57600) # Baudrate must match rate set in sketch
>>> a.pin_mode(13, firmata.OUTPUT)
>>> a.digital_write(13, firmata.HIGH) # LED on pin 13 on
>>> a.digital_write(13, firmata.LOW) # LED on pin 13 off
>>> a.serial.close()
- Note that the major_version and minor_version properties appear not to get set in the Arduino instance.
Links
Additional links