Python programming without uploading a sketch

Good day, everyone!

I am new to the Arduino world and have a quick question about controlling the Arduino Uno's LED with Python.

I wrote a sketch that turns the LED on and off via pin 13. And I also wrote a Python script that uses pyserial to communicate with the Uno over port /dev/ttyACM0 (I am running Ubuntu 20.04 on my main developer laptop).

Most of the Arduino Python tutorials first show how to upload a sketch and then how to use Python to communicate with the sketch that does the actual heavy lifting of flipping the LED on and off.

Can Python communicate directly with the Arduino's pins and registers without having a sketch in between?

Thanx for your replies!

Can Python communicate directly with the Arduino's pins and registers without having a sketch in between?


But you can run Python on some Arduino, at least that’s what 15 seconds of googling turns up.

Or you might want to find or write a more capable general purpose “light lifting” sketch to upload. So it really does just some low level stuff and you will be able to heavy lift on the Python (PC) side.


This Simple Python - Arduino demo may be of interest.


Hello man !

I've been there and you got a few things you can do that actually helps achieve your goal.

First you can try to use the pyfirmata module to send sketches via python.

But to be honnest i never succeeded in making it work efficiently.

The second option is what I did with a piece of software i'm currently developping, and it's a bit trickier.

You need to "steal" the arduino compiler, linker and uploader.
I can't guide you through this process as it is really tedious. But I can give you some tracks ; in your arduino IDE activate the "show verbose during output" for compiler and uploading in the preferences.
Then copy paste the command lines.
Track down the files and try to understand those commands so you can copy paste everything in your project folder.
Then use python os.system() function to execute those functions in the command line.

These are just tracks on what you could do. You actually need to understands the role of the compiler , linker etc.

Don't hesitate to message me if you have more precise questions about that.

Cheers mate.

I want to thank everyone who provided insight and guidance. I have a much better understanding of the Arduino programming model and am able to interact with my Uno with both Python and C. That's way more progress than I thought I'd ever make in a little more than a week of having my Uno. Perfect!!!

Next up: Java!


(Haven't had this much fun with low level systems programming since first learning C way back in the mid 80s!)

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