Skip to content
A Python-Arduino-Prototyping-API fork gone wild
Python Processing
Branch: master
Clone or download
Latest commit 10417f5 May 7, 2015
Type Name Latest commit message Commit time
Failed to load latest commit information.
arduino UTF-8 error May 6, 2015
MIT-license.txt init Sep 23, 2012 lets tell them the example is new Sep 23, 2012
prototype.pde - added break before the '99' case, just to be sure nothing goes wron… Apr 14, 2013 init Sep 23, 2012 init Sep 23, 2012 init Sep 23, 2012

Python Arduino Prototyping API v2

This is a project based on the original Python Arduino Prototyping API. I started a fork and after a while the whole thing was getting too different to make a pull request so I just put it here. The old project had wierd things going on to handle the communication, where I rely on parseInt() to do the work for me. There were also problems with analogWrite(), which is working in this version.

Major changes:

  • .pde is completely redone
  • Small changes in the file
  • Added examples

Here follows the original README (with updated example):

© 2009-2010 Akash Manohar J under the MIT License

The Python Arduino Prototyping API helps you to quickly prototype Arduino programs, without having to repeatedly load the program to the Arduino board.


  1. Load prototype.pde onto your Arduino dev board.
  2. Import the arduino lib in your python script.


Arduino.output(list_of_output_pins) - set the output pins

Digital I/O

  1. Arduino.setHigh(pin_number)
  2. Arduino.setLow(pin_number)
  3. Arduino.getState(pin_number)
  4. Arduino.getState() - returns true if pin state is high, else it returns false.

Analog I/O

  1. Arduino.analogRead(pin_number) - returns the analog value
  2. Arduino.analogWrite(pin_number, value) - sets the analog value


1.) Arduino.turnOff() - sets all the pins to low state

2.) Arduino.close() - closes serial connection. Using this makes sure that you won't have to disconnect & reconnect the Arduino again to recover the serial port.

Usage example

from arduino import Arduino
import time

b = Arduino('/dev/ttyUSB0')
pin = 9

#declare output pins as a list/tuple

for xrange(10):
    print b.getState(pin)
    print b.getState(pin)

You can’t perform that action at this time.