Firmata: Difference between revisions
From ICO wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 16: | Line 16: | ||
sudo add-apt-repository ppa:fkrull/deadsnakes | sudo add-apt-repository ppa:fkrull/deadsnakes | ||
sudo apt-get update | sudo apt-get update | ||
sudo apt-get install python3.5 | sudo apt-get install python3.5 python3-serial | ||
Ubuntu 15.10 already has Python 3.5 available, simply install it: | Ubuntu 15.10 already has Python 3.5 available, simply install it: | ||
sudo apt-get install python3.5 | sudo apt-get install python3.5 python3-serial | ||
Ubuntu 16.04 will ship Python 3.5 by default | Ubuntu 16.04 will ship Python 3.5 by default just add serial module: | ||
sudo apt-get install python3-serial | |||
Install PyMata for Python 3.5: | Install PyMata for Python 3.5: |
Revision as of 11:39, 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 python3-serial
Ubuntu 15.10 already has Python 3.5 available, simply install it:
sudo apt-get install python3.5 python3-serial
Ubuntu 16.04 will ship Python 3.5 by default just add serial module:
sudo apt-get install python3-serial
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()
Plug the Arduino to your machine via USB cable and run the code:
python3.5 test.py