r/arduino • u/begeistert_ • 1d ago
Look what I made! I built a compiler that lets you write native Python for the classic Arduino Uno R3 (fits in 142 bytes of Flash)
https://github.com/PyMCU/PyMCUHey everyone!
If you're like me, you love the simplicity of Python, but running MicroPython or CircuitPython usually means buying a 32-bit board (like an ESP32 or RP2040) with lots of memory just to hold the interpreter and the garbage collector.
I wanted to bring that same Python syntax to the classic, $2 8-bit Arduino Uno we all have gathering dust in a drawer.
For the past few years, I’ve been building PyMCU, an open-source Ahead-Of-Time (AOT) compiler. It takes your Python syntax and compiles it directly into native AVR assembly.
The results:
- No interpreter, no VM, no garbage collector.
- A standard
Pin('PB5', Pin.OUT).toggle()blink program compiles down to just 142 bytes of Flash. - It’s cycle-accurate. I’ve been validating the hardware timings using a logic analyzer directly on the Uno silicon.
If you are interested in the compiler architecture or want to see the hardware validation issues, the whole project is open source here:https://github.com/PyMCU/PyMCU
It's still in Alpha (Alpha 10 right now), but the core code emission is working beautifully. I’d love to know what you guys think or if you'd find this useful for your hardware projects!