Saturday, September 20, 2014

Firmata + Python/pyFirmata, control Arduino from Raspberry Pi

This post show steps to install pyFirmata, and also python-serial, on Raspberry Pi. Such that we can program Arduino Uno (with StandardFirmata sketch) using Python.

- Make sure you have Arduino IDE installed on Raspberry Pi.

- Install pyFirmata and python-serial, enter the command in Terminal.
$ sudo apt-get install python-pip python-serial
$ sudo pip install pyfirmata


To test your setup:

- Upload StandardFirmata sketch to your Arduino.
In Arduino IDE, click File > Examples > Firmata > StandardFirmata
Compile and upload the sketch to Arduino Uno.

- Try on Python IDLE
Start icon > Programming > IDLE to start Python
Enter the code:
>>> from pyfirmata import Arduino, util
>>> board = Arduino('/dev/ttyACM0')
>>> board.digital[13].write(1)
>>> board.digital[13].write(0)


No comments:

Post a Comment