The short answer is directly from an Arduino board.
When you "upload" a sketch, the Arduino IDE compiles your human-readable code into a machine-language binary file (.hex). This binary is what gets stored on the board. The original variable names, comments, and structure are lost during this conversion. download code from arduino to pc
To get the binary file from your Arduino, you’ll need a command-line tool called , which is included with the official Arduino IDE . Step-by-Step for Windows Users: How to copy a program from Arduino to PC - Robotics The short answer is directly from an Arduino board
If you’ve ever found yourself with an Arduino board that’s running a project you built months ago but realized you’ve lost the original code on your computer, you aren't alone. Downloading code from an Arduino back to a PC is a common request, though the process is more complex than simply clicking "Download." Can You Download Source Code From an Arduino? The original variable names, comments, and structure are
However, you download that compiled binary (.hex) file. While you can't easily edit it like a standard sketch, you can use it to clone the program onto another identical Arduino board. Method 1: Retrieving the Compiled Binary (.hex)