Writing numbers bigger than 1 byte to EEPROM

Instead of having to create a new tab and copy that template stuff for each and every sketch that is going to use this, you can do the following, as I have now done:

In your Arduino libraries directory, create a new subdirectory. Call it, say, EEPROMAnything. Navigate to that directory, and with your favorite programming editor (probably vim, right?), create a file named EEPROMAnything.h (For sanity's sake, give it the same name as the directory, but with the .h suffix.)

Paste the template code from my previous example to EEPROMAnything.h Not the main sketch, just the template stuff. (Don't forget the #include <WProgram.h> directive.)

If the Arduino IDE is open, close it.

Open the Arduino IDE and create a new sketch that is like the one that I showed. You don't need the tab stuff here, because now you have a library that will be included when the sketch is compiled. (See Footnote.)

Ta-daa!

Regards,

Dave

Footnote: Here's a way to make sure that Arduino can find your new library:

Create the main sketch without the #include "EEPROMAnything" directive (or comment it out), but, (And this is important. Really): You do still need the #include <EEPROM.h> directive in your main sketch. Really.

Now from Arduino Sketch->Import Library menu you should see your new library. Click on it and you will get the following statement at the top of your sketch:

#include <EEPROMAnything.h>

Ta-daa! (But I already said that.)

Let's do one more thing.

Now, under the EEPROMAnything directory, create a subdirectory named examples

Navigate to that subdirectory and create another subdirectory. Name it, say Ints

Navigate to that subdirectory and use your text editor to create a file named Ints.pde (Must be same name as its directory, but with the .pde suffix.) Paste my little EEPROM integer write/read sketch into that file. You have already run this, so you know it works.

The next time you open the Arduino IDE, select the File->Examples menu item. You should see the EEPROMAnything library with a little triangle, and you should be able to select Ints and see the sketch open up.

(I won't say "Ta-daa" again, but you know...)

Finally (I promise. Really):

Heck, since the EEPROM library is part of the standard Arduino distribution and the Anything functions are so handy (and can't just be pasted directly in your main sketch anymore as documented in the playground), maybe the Arduino developers could even make the Anything functions part of the distribution. How about it? Would there be a downside to that?