# Can C# or Python compile to Arduino machine code?

**URL:** <https://forum.arduino.cc/t/can-c-or-python-compile-to-arduino-machine-code/1272845>\
**Category:** Programming\
**Created:** [June 18, 2024, 12:02am UTC](https://forum.arduino.cc/t/can-c-or-python-compile-to-arduino-machine-code/1272845 "2024-06-18T00:02:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![absaintdane](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@absaintdane](https://forum.arduino.cc/u/absaintdane)\
**Post date:** [June 18, 2024, 12:02am UTC](https://forum.arduino.cc/t/can-c-or-python-compile-to-arduino-machine-code/1272845/1 "2024-06-18T00:02:18Z")

</div>

Hey there,

Every resource I see keeps mentioning how C# or python can be run from your PC to communicate with the board. But is there some way to compile C# or Python code INTO an Arduino sketch that can then be uploaded to the board?

Thank you!

Ab

---

<div class="post-metadata">

**Author:** ![kolaha](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/kolaha/32/966427_2.png) [@kolaha](https://forum.arduino.cc/u/kolaha)\
**Post date:** [June 18, 2024, 12:14am UTC](https://forum.arduino.cc/t/can-c-or-python-compile-to-arduino-machine-code/1272845/3 "2024-06-18T00:14:49Z")

</div>

> [@Delta\_G](#):
>
> It isn't compiled

actually it is, if you want

@absaintdane i used for short time an Arduino plug-in for VS Code 2019.  
any way, i think, you can generate .o files and link it with avrdude

---

<div class="post-metadata">

**Author:** ![kolaha](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/kolaha/32/966427_2.png) [@kolaha](https://forum.arduino.cc/u/kolaha)\
**Post date:** [June 18, 2024, 12:20am UTC](https://forum.arduino.cc/t/can-c-or-python-compile-to-arduino-machine-code/1272845/5 "2024-06-18T00:20:20Z")

</div>

i have compiled Python script for Windows

---

<div class="post-metadata">

**Author:** ![westfw](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/westfw/32/213443_2.png) [@westfw](https://forum.arduino.cc/u/westfw)\
**Post date:** [June 18, 2024, 12:24am UTC](https://forum.arduino.cc/t/can-c-or-python-compile-to-arduino-machine-code/1272845/7 "2024-06-18T00:24:45Z")

</div>

> [@Delta\_G](#):
>
> I don't know of anything that makes machine code from C#. AFAIK it works like Java.

Byte-code interpreted. With a rather large "interpreter."  
IIRC, there were some [arduino-size boards that claimed to run .net micro](https://www.adafruit.com/product/1104) (not quite sure if that includes C#) programs directly, based on some relatively powerful ARM chips. They were pretty expensive, didn't catch on, and were discontinued; I'm not sure if there was a replacement.

The microPython (Raspberry Pi Pico) and circuitPython (many Adadfruit boards based on ARM or ESP chips) have gained more traction - they run a python interpreted on the chip. (NOT via a Python to Machine Code compiler.)

None of the AVR-based Arduinos (Uno 3, Nano v3, Nano Every, Mega V3, etc) will run either python or .net interpreters; they simply lack the resources (mostly memory.)

---

<div class="post-metadata">

**Author:** ![absaintdane](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@absaintdane](https://forum.arduino.cc/u/absaintdane)\
**Post date:** [June 18, 2024, 12:29am UTC](https://forum.arduino.cc/t/can-c-or-python-compile-to-arduino-machine-code/1272845/9 "2024-06-18T00:29:39Z")

</div>

Hey guys, thanks for the replies!

I understand the interpreters won't run on most boards. I meant if there's a way to compile the code directly into machine code/sketch OR into C/C++ which can then be compiled into machine code/sketch.

---

<div class="post-metadata">

**Author:** ![kolaha](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/kolaha/32/966427_2.png) [@kolaha](https://forum.arduino.cc/u/kolaha)\
**Post date:** [June 18, 2024, 1:09am UTC](https://forum.arduino.cc/t/can-c-or-python-compile-to-arduino-machine-code/1272845/11 "2024-06-18T01:09:22Z")

</div>

> [@Delta\_G](#):
>
> Does that video

none of the above. deleted.

upd

> you can use `cython` to generate a C file out of the Python `.py` file

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [December 15, 2024, 1:09am UTC](https://forum.arduino.cc/t/can-c-or-python-compile-to-arduino-machine-code/1272845/12 "2024-12-15T01:09:41Z")

</div>

Closed on December 15, 2024, 1:09am UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
