Storing when an Arduino sketch was Compiled
/// These are found and replaced by the compiler.#define CompileDate __DATE__ #define CompileTime __TIME__String CompileYear = CompileDate;/// These are for returning copyright information, and storing this information in the code.const String Copyright = "Philip McGaw"; ///< Copyright company / person's name.String Product = "ProjectName"; ///< Project name. (Updated when I make a release).String Serial_Number = "-1"; ///< Placeholder - This is the serial number of the microprocessor.const int Software_Version = 1; ///< Firmware version. (Updated when I make a release). |
This is an example of the code allowing the data to be sent out via the serial port.
CompileYear = CompileYear.substring(7, 11); ///< Cuts the string so it just contains the year. Serial.println((String) "© " + Copyright + " " + CompileYear + " - " + Product);Serial.println((String) "Software Version: \t\t" + Software_Version + " (" + CompileDate + " " + CompileTime + ")");Serial.println((String) "Hardware Version: \t\t" + Hardware_Rev);Serial.println((String) "Serial Number: \t\t\t" + Serial_Number); |
Serial_Number and Hardware_Rev should both be -1, as they are not set in the code above.
Source: Storing when an Arduino sketch was Compiled – PhilipMcGaw.com