Firmata: Difference between revisions
From ICO wiki
Jump to navigationJump to search
Created page with " ==Setting up Arduino== Clone Arduino library to your machine: git clone http://github.com/firmata/arduino ~/Documents/Arduino/libraries/Firmata Select Examples -> Firm..." |
No edit summary |
||
| Line 34: | Line 34: | ||
from pymata_aio.pymata3 import PyMata3 | from pymata_aio.pymata3 import PyMata3 | ||
from pymata_aio.constants import Constants | from pymata_aio.constants import Constants | ||
# instantiate the pymata_core API | # instantiate the pymata_core API | ||
board = PyMata3() | board = PyMata3() | ||
# set the pin mode | # set the pin mode | ||
board.set_pin_mode(13, Constants.PWM) | board.set_pin_mode(13, Constants.PWM) | ||
for j in range(0, 10): | for j in range(0, 10): | ||
for i in range(0, 255): | for i in range(0, 255): | ||
| Line 46: | Line 46: | ||
for i in range(255, 0, -1): | for i in range(255, 0, -1): | ||
board.analog_write(13, i) | board.analog_write(13, i) | ||
# reset the board and exit | # reset the board and exit | ||
board.shutdown() | board.shutdown() | ||
Revision as of 11:04, 20 February 2016
Setting up Arduino
Clone Arduino library to your machine:
git clone http://github.com/firmata/arduino ~/Documents/Arduino/libraries/Firmata
Select Examples -> Firmata -> StandardFirmata from the menu and hit the Upload button.
Setting up Ubuntu box
For Ubuntu 14.04 first add Python 3.5 repository:
sudo add-apt-repository ppa:fkrull/deadsnakes sudo apt-get update sudo apt-get install python3.5
Ubuntu 15.10 already has Python 3.5 available, simply install it:
sudo apt-get install python3.5
Ubuntu 16.04 will ship Python 3.5 by default so need to install additional packages.
Install PyMata for Python 3.5:
git clone https://github.com/MrYsLab/pymata-aio cd pymata-aio sudo python3.5 setup.py install
Create test.py with following code:
from pymata_aio.pymata3 import PyMata3
from pymata_aio.constants import Constants
# instantiate the pymata_core API
board = PyMata3()
# set the pin mode
board.set_pin_mode(13, Constants.PWM)
for j in range(0, 10):
for i in range(0, 255):
board.analog_write(13, i)
for i in range(255, 0, -1):
board.analog_write(13, i)
# reset the board and exit
board.shutdown()