Tuesday, August 7, 2018

Hello Arduino and FIRMATA

Firmata is a protocol for communicating with microcontrollers from software on a computer
Like Arduino for example :
In essence it turns your Arduino device into a slave with a simple provided sketch. Then using the python/or any other language you can interface the Arduino via Serial bus and exposed API provided by the Firmata system

  1. Install arduino IDE
  2. Add dialup group to user `sudo adduser $USER dialout
  3. Upload Firmata to arduino
    1. File -> Examples -> Firmata -> StandardFirmata
  4. Install python library
    1.  sudo pip install pyfirmata
  5. Write some code

code example to turn on output 13 (build-in led)

from pyfirmata import Arduino, util
board = Arduino('/dev/ttyACM0')
board.digital[13].write(1)

Reference

No comments: