Skip to main content
added 364 characters in body
Source Link
Majenko
  • 105.9k
  • 5
  • 82
  • 139

You can use the macro __FILE__ to get the filename that is being compiled. That may not be your INO file, but may be some derivative of it.

Serial.println(__FILE__);

You also get some other handy macros:

__DATE__
The date the sketch was compiled

__TIME__ 
The time the sketch was compiled

__LINE__
The line number where __LINE__ is being used

The combination of __FILE__ and __LINE__ is commonly used for debugging:

Serial.prinln("Error 23 at line " __LINE__ " of " __FILE__);

You can use the macro __FILE__ to get the filename that is being compiled. That may not be your INO file, but may be some derivative of it.

Serial.println(__FILE__);

You can use the macro __FILE__ to get the filename that is being compiled. That may not be your INO file, but may be some derivative of it.

Serial.println(__FILE__);

You also get some other handy macros:

__DATE__
The date the sketch was compiled

__TIME__ 
The time the sketch was compiled

__LINE__
The line number where __LINE__ is being used

The combination of __FILE__ and __LINE__ is commonly used for debugging:

Serial.prinln("Error 23 at line " __LINE__ " of " __FILE__);
Source Link
Majenko
  • 105.9k
  • 5
  • 82
  • 139

You can use the macro __FILE__ to get the filename that is being compiled. That may not be your INO file, but may be some derivative of it.

Serial.println(__FILE__);