My arduino is doing stuff and i can control my servos with the potentiometer. I have written a few sketches. I closed all sketch windwos. Has anyone an idea how to find out which program my Arduino currently is running?
Thank you very much
Fanta
My arduino is doing stuff and i can control my servos with the potentiometer. I have written a few sketches. I closed all sketch windwos. Has anyone an idea how to find out which program my Arduino currently is running?
Thank you very much
Fanta
Hello fantafauna
Take a view into the sketch book to be found inside the IDE.
Inside the sketch I´m using the following lines of code:
Serial.begin(9600);
Serial.print("File: ");
Serial.println(__FILE__);
Serial.print("Projekt: ");
Serial.println("myProject");
It;s impossible to read sourcecode back from the controller, that you cant download the program and directly compare it with saved sketches. But you can download the binary code and compare it with ones, produced by compiler.
okay but then i have to now which sketch it is running right now, to write that into the sketch. but yes i also thought of serial monitor - thank you ![]()
have you tried looking at the serial monitor to see if it prints anything? try different bit rates
compiling and uploading a sketch creates multiple files
You can lookup these files and look at the last changed timestamp

If you have done a lot of compilings after the one you are interested in.
Always add something like this to all your sketches
void PrintFileNameDateTime() {
Serial.println( F("Code running comes from file ") );
Serial.println( F(__FILE__) );
Serial.print( F(" compiled ") );
Serial.print( F(__DATE__) );
Serial.print( F(" ") );
Serial.println( F(__TIME__) );
}
best regards Stefan
That’s a good point. Perhaps we should all be putting a serial print in out setup just to let us know which sketch version we are using.
It is indeed a good idea to identify the sketch via the serial port as a check, but if you didn't and don't know what you have, what do you care? Just burn the sketch you want to the Arduino and move on.
This "problem" is why every Arduino program I write starts by outputting the program name and version to the serial port ![]()
plus path to source code.
Bad idea if you use boards with native USB
To see it, you need while(!Serial) in setup() which will block if you don't connect your board to a PC and open a terminal program; not all programs need that terminal program (or even a PC).
Alternatively, one can use print in loop() but that might have unwanted side affects if you don't take precautions; your sketch might become very sluggish.
To solve this problem an IO-pin could be configured as input_pullup and only if this IO-pin goes low print the source-code-information.
best regards Stefan
Good idea! Never thought of that.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.