skip to navigation
skip to content

Not Logged In

nanpy 0.8

Use your Arduino board with Python.

Description

The main purpose of Nanpy is making programmers' life easier, giving them something to create prototypes faster and use Arduino in a simpler way, thanks to a simple and powerful language like Python. Also Nanpy can run on RaspberryPi (tested with Raspbian http://www.raspbian.org/) so you can use it for communicating with Arduino :)

Let's start with a classic example, turn on a led placed in the 13th pin..

Arduino.pinMode(13, Arduino.OUTPUT)

Arduino.digitalWrite(13, Arduino.HIGH)

There are a lot of projects able to do that. Nanpy can do more! Nanpy is easily extensible and can theoretically use every library, allowing you to create how many objects you want. We started supporting basic Arduino's functions and OneWire, Lcd, Tone, Stepper and Servo libraries and they're still incomplete. Let's try to connect our 16x2 lcd screen on pins 7, 8, 9, 10, 11, 12 and print something!

lcd = Lcd([7, 8, 9, 10, 11, 12], [16, 2])

lcd.printString("Hello World!")

really straightforward now, isn't it? :)

Multithreading

What happens if you call methods in an async context? Nothing bad, all works! every call is mutually exclusive.. For example, suppose that two threads need to write on the same Lcd and in different positions at the same time... well, just call printString on the Lcd object specifying the position (row and column)

Thread_1 lcd.printString("Hello First Row!", 0, 0)

Thread_2 lcd.printString("Hello Second Row!", 0, 1)

Dependencies

Python (2.2 or later)

python-distribute (http://pypi.python.org/pypi/distribute)

python-serial

How to build and install

Nanpy is composed by a Python part, that provides a library to use Arduino via Python and a server firmware. You can install Nanpy on a Raspberry too :)

To install Nanpy just type (as root, requires python-setuptools):

python setup.py install

To build the firmware type:

cd firmware

export BOARD=uno (in case you use UNO board. Type 'make boards' for a complete list)

make

and then upload it on your board:

make upload

How to use

Serial communication

Nanpy autodetects the serial port for you, anyway you can specify another serial port and baudrate manually:

from nanpy import serial_manager

serial_manager.connect('/dev/ttyACM1')

Import modules

Import all the modules you need :)

from nanpy import Arduino

from nanpy import (OneWire, Lcd)

...

How to contribute

Nanpy needs a lot of work to be a great and stable instrument. You can contribute with patches (bugfixing, writing improvements, creating support for a new library not included in Nanpy yet, writing examples and so on), writing documentation, reporting bugs 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>

License

This software is released under MIT License. Copyright (c) 2012 Andrea Stagi <stagi.andrea@gmail.com>

 
File Type Py Version Uploaded on Size
nanpy-v0.8.tar.gz (md5) Source 2013-02-19 43KB
  • Downloads (All Versions):
  • 28 downloads in the last day
  • 165 downloads in the last week
  • 645 downloads in the last month
  • Author: Andrea Stagi
  • Maintainer: Andrea Stagi
  • Home Page: https://github.com/nanpy/nanpy
  • Bug Tracker: https://github.com/nanpy/nanpy/issues
  • Download URL: https://github.com/nanpy/nanpy/tags
  • Keywords: arduino library prototype raspberry
  • License:
    MIT License
    
    Copyright (c) 2012-2013 Andrea Stagi <stagi.andrea@gmail.com>
    
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
    
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
    
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
  • Package Index Owner: astagi
  • DOAP record: nanpy-0.8.xml