0

I know that I can program Arduino with python but is it possible to make every project, which can be completed by normal IDE?

dda
  • 1,588
  • 1
  • 12
  • 17
Tanishq Jaiswal
  • 181
  • 1
  • 9

3 Answers3

3

I imagine you want to use python because you are already familiar with it, know your way around the syntax, etc. But I would advice against this line of thinking, because microcontrollers need a little more of "low-level" thinking (given the limited resources they generally have) and because of that, it's probably best if you learn some C/C++.

The arduino programming framework provides some not-so-low-level libraries and tools (like the arduino IDE itself) to make it easy for non-C programmers to learn C-like programming.

However, if you want to use python as a proof of concept or anything else, sorry about the misunderstanding! :)

jotadepicas
  • 326
  • 5
  • 13
1

The direct answer is almost certainly not.

There are some auspicious developments so that you might be able to adapt a specific open source Python package, but the resulting software would require a special Arduino board with an MCU chip with much more SRAM and a higher clock speed than we usually see on Arduino boards.

Discussion

I have looked several times and have never found anything.

I did find a "stripped down" implementation of a Python 3.3 interpreter called Micro Python. The software was developed hand in hand with MicroPy, an ARM-based single board computer (also described at the MicroPython website). MicroPy is closer to a Raspberry Pi or Beaglebone than an Arduino. However, the software environment is less complex because the MicroPy doesn't require a Linux-based or other operating system.

The base Micro Python package software package seems to require about 110KB of SRAM to boot up and expects a 1 MB SD chip with a boot record and MicroPython on it.

The Micro Python software was released under the MIT open source license so, in theory, a clever person could adapt it for the Arduino if they built a board with a really powerful chip SD socket.

Although the Micro Python/MicroPy package is very appealing, I don't think I would head down the path. I would rather be programming for hardware that is available from more than one source.

Another potential issue is that the Micro Python implementation uses a mark and sweep garbage collector which might tie up the processor for 4 msec at time. Depending on your application a 4 msec busy period might not be acceptable.

WesR
  • 111
  • 2
0

Not really, since python is an interpreted programming language. If you are not new to the microcontrollers' world and have same experience, maybe this Board is you what you want. More powerful than Arduino and completely programble using Python 3.

Topic: Can I use Python to program Arduino?

Dave
  • 349
  • 1
  • 6
  • The fact that Python is interpreted (or more accurately, byte-compiled for a VM) is not actually relevant. There are several Python VMs for AVR and ARM. – Ignacio Vazquez-Abrams Jan 03 '15 at 22:22
  • Not exactly. micro controllers, by virtue of not having an os, can only execute compiled code. Hence, using Python is not good as you'll run into a lot of runtime errors and stuff that can be figured out when compiling (exact memory allocation). C++ is better suited. – xyz Jan 04 '15 at 11:40
  • 2
    That's a silly thing to say. Not having an OS means that os and sys are less useful, but an allocator is by no means dependent on an OS. And assuming a working VM implementation, there's little to no reason why a Python program should be any more or less difficult to debug than a C++ application (other than the absence of e.g. debugWire, which can be emulated at a higher level regardless). – Ignacio Vazquez-Abrams Jan 04 '15 at 17:07
  • @prakharsingh95 Yes, they can only execute compiled code. The compiled code is the interpreter. – Anonymous Penguin Jan 04 '15 at 20:09
  • @AnnonomusPenguin, an interpreter is the main executing instance which executes Python code. Compiled code allows static scheduling, and memory management, interpreted code will have a harder time optimising. Python programs would need to be internally compiled to byte code , against pythons nature, or the program would need to an interpreter, like you said, which will kill performance. But of course, c++ here makes sense to me, but Python might be feasible. – xyz Jan 04 '15 at 20:16
  • @prakharsingh95 why would it have to be compiled to byte code? I see no reason, besides program space, to believe that it couldn't at least run a slow, stripped down version of Python from an SD card or EEPROM. – Anonymous Penguin Jan 04 '15 at 20:18
  • @AnnonomusPenguin, i confess, I don't know how much compromise using python makes, but to me, for tiny processors, nothing beats compile and optimized code. And compiled Python is very hard and probably never done, so people flash interpreters to execute Python, hence the overhead. – xyz Jan 04 '15 at 20:21
  • @prakharsingh95 speed is a very different thing than possibility. I've seen an AVR chip run Linux somewhere online! BTW it's already been done (kinda): https://micropython.org/ – Anonymous Penguin Jan 04 '15 at 20:24
  • @AnnonomusPenguin yeah, I agree, it's possible, but just doesn't seem efficient to me :P – xyz Jan 04 '15 at 20:25
  • @prakharsingh95 that link has been already posted by me yesterday. But is not an Arduino board – Dave Jan 04 '15 at 20:29
  • @prakharsingh95: Python already is compiled to bytecode, so it is hardly "against Python's nature". – Ignacio Vazquez-Abrams Jan 05 '15 at 01:59
  • @IgnacioVazquez-Abrams Indeed, from this reference, Python is indeed compiled to bytecode, but then is still interpreted. I had meant Python is not compiled to machine code (hex code for Arduino). Like AnnonomusPenguin mentioned, the Python interpreter is loaded on the MCU, not the compiled machine code for the user program. – xyz Jan 05 '15 at 06:36