What sketch is loaded?

All my Arduino look the same, so when I pick one up off my workbench I don't know which sketch is loaded on it.

I think in the future, I will start each sketch by printing some identifying info to the serial port.

Is this how other people approach it?

Is this how other people approach it?

I, not.

Tag them by using Sticky Tape.

Why would you have multiple bare arduinos with different programs on them? I have some that are actually in robots and sometimes another one I use to test out things that just use the serial monitor, but I never have two arduinos not attached to anything that I'm using at the same time.

I can't imagine there would be much point having multiple bare arduinos with the same program on them?

(This reply is deliberately useless).

...R

WizenedEE:
Why would you have multiple bare arduinos with different programs on them?

One possibility:

void setup(void)
{
    Serial.begin(115200);
    Serial.println(__FILE__);
    Serial.println(__DATE__);
    Serial.println(__TIME__);
}

void loop(void)
{
}

Does the Arduino compiler waste AVR memory by storing that data when it uploads a sketch?

If so how can I stop it?

...R

Robin2:
Does the Arduino compiler waste AVR memory by storing that data when it uploads a sketch?

If so how can I stop it?

...R

[quote author=Jack Christensen link=topic=162669.msg1215898#msg1215898 date=1366893645]
One possibility:

void setup(void)

{
   Serial.begin(115200);
   Serial.println(FILE);
   Serial.println(DATE);
   Serial.println(TIME);
}

void loop(void)
{
}

[/quote]
Serial.println(F(__FILE__));?

KrazeyNKrusty:
All my Arduino look the same, so when I pick one up off my workbench I don't know which sketch is loaded on it.

I think in the future, I will start each sketch by printing some identifying info to the serial port.

Is this how other people approach it?

Yes I often do that. I also sometimes have a 'press any key to run' type waiting function in the setup function so as to not start running the main sketch until I want it to, such as allowing me to get the serial monitor running or other things I might want to do manually before the sketch starts running the main loop function.

Lefty

I do something similar, but concatenating all these values into a single string:

Serial.println(__FILE__ " " __DATE__ " " __TIME__);

I'm never close enough to the RAM limit to bother with putting the string into progmem, but you could if you wanted.

Does the Arduino compiler waste AVR memory by storing that data when it uploads a sketch?

No, those are compiler constants and don't take up any more memory than the (probably) thousands of #defines in gcc. They will only take up memory if you use them - and even then they probably go into flash.

I prefer to just reprogram every time I want to do anything, it only takes a second ,and you might as well if you're opening up the IDE to serial monitor anyway. That way I know I'm working with the code I want and the most recent version etc.

Just out of curiosity - does that mean that the code that gave rise to my question Serial.println(__FILE__); won't work? or does it mean that if I included that code in a sketch the compiler would then upload the data as part of the sketch?

...R

KeithRB:

Does the Arduino compiler waste AVR memory by storing that data when it uploads a sketch?

No, those are compiler constants and don't take up any more memory than the (probably) thousands of #defines in gcc. They will only take up memory if you use them - and even then they probably go into flash.

They are pre-defined macros, they will be treated like any #define you don't use. If you need it, it is treated as a compile time constant and loaded from PROGMEM, if you don't use it, it is ignored.

I am sure a quick sketch with a glance at the assembler output will clear it up.

Actually, I am not so clear on the PROGMEM part.

If you do a serial.print(12) I am pretty sure the 12 comes form PROGMEM.

I don't know about serial.print("12").

KeithRB:
Actually, I am not so clear on the PROGMEM part.

If you do a serial.print(12) I am pretty sure the 12 comes form PROGMEM.

I don't know about serial.print("12").

Try serial.println(F("12"));

that will print the string "12" from Flash memory. This feature - the F() macro - was introduced with Arduino 1.0

So I assume Serial.println(F(file));

would work, too.

KeithRB:
So I assume Serial.println(F(file));

would work, too.

Yes, as reply #6 said.