Take the 2-minute tour ×
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

I am not very skilled with the C Language and I was wondering if there is a way in which python could be used to program an Arduino. This would most likely require a different IDE in order to be able to debug the scripts them self.

share|improve this question
1  
There are couple alternatives for programming Arduino, one of them is BitLash and there is a basic interpreter. There are couple options when you search the Internet, but learning C/C++ will pay off in the end. –  jippie Feb 12 at 17:06
    
Thanks, I am actually getting a bit better at C, just not as good as I am with Python. –  JVarhol Feb 12 at 17:07
1  
related, more general question: "Arduino programming options other than C++" –  David Cary Feb 15 at 4:15
add comment

3 Answers 3

up vote 4 down vote accepted

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).

share|improve this answer
    
Very Interesting, thanks –  JVarhol Feb 12 at 16:44
add comment

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.

share|improve this answer
    
So the board has to be plugged into a computer in order to actually run the code? –  JVarhol Feb 12 at 16:19
    
@JVarhol Oddly, yes. –  AsheeshR Feb 12 at 16:23
    
Well, that pretty crappy. It would be easier to use a Raspberry Pi. –  JVarhol Feb 12 at 16:25
add comment

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)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.