Use your Arduino board with Python. http://pypi.python.org/pypi/nanpy
- ::
- a = ArduinoApi() a.pinMode(13, a.OUTPUT) a.digitalWrite(13, a.HIGH)
from nanpy import Lcd lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2]) lcd.printString('Hello World!')
really straightforward now, isn't it? :)
Nanpy autodetects the serial port for you, anyway you can manually specify another serial port:
from nanpy import SerialManager connection = SerialManager(device='/dev/ttyACM1')
and use it with your objects
- ::
- from nanpy import ArduinoApi a = ArduinoApi(connection=connection) a.pinMode(13, a.OUTPUT) a.digitalWrite(13, a.HIGH)
You can specify how many SerialManager objects you want and control more than one Arduino board within the same script.
First of all, you need to build the firmware and upload it on your Arduino, to do that clone the nanpy-firmware repository on Github or download it from PyPi.
git clone https://github.com/nanpy/nanpy-firmware.git cd nanpy-firmware ./configure.sh
To install Nanpy Python library on your master device just type:
pip install nanpy
Nanpy still needs a lot of work. You can contribute with patches (bugfixing, improvements, adding support for a new library not included in Nanpy yet, writing examples and so on), writing documentation, reporting bugs, creating packages or simply spreading Nanpy through the web if you like it :) If you have any doubt or problem, please contact me at stagi.andrea@gmail.com
Do you want to support us with a coffee? We need a lot of caffeine to code all night long! if you like this project and you want to support us, please donate using Paypal
This software is released under MIT License. Copyright (c) 2012-2015 Andrea Stagi stagi.andrea@gmail.com