Programming an Arduino using Python, rather than C/C++

It's going to be extremely difficult to get any kind of Python script running directly on the Arduino. The reason is that it's an interpreted language, so you would need the interpreter on-board in addition to the plain text script. There's probably not going to be enough memory for all of that.

Your best bet would probably be finding a way to compile a Python script to native machine code (which is how C/C++ works). I believe there are projects around to do something like that for other platforms, but (as far as I know) none which does it successfully for Arduino yet.

You might find some more useful information on this question at Stack Overflow: Is there a way to "compile" Python code onto an Arduino (Uno).


Yes, it is (somewhat) possible to program the Arduino using Python. One such project on Github is the Python Arduino Prototyping API v2. It provides very basic functionality such as digital I/O and analog I/O.

This can be used for very simple projects.


*This project is a bit of a hack at "programming" the board using the serial connection. It passes the commands over the serial connection to a sketch running on the board which then "executes" the Python command.


There is a project which brings a Python virtual machine to micro-controllers, including the Arduino Mega.

Here's a quote from the Ardunio Mega README, which gives a feel for what this could be like (though, I've not tested this!):

The following is an example session using ipm::

ipm> import avr, sys
ipm> avr.ddrA(0xff)
ipm> avr.portA(0)       # Pins 22-29 all at 0 V
ipm> avr.portA(0xa5)
ipm> sys.heap()
(2622, 7424)