❏ Next, verify that the Arduino IDE can find the
storeEEPROM library. Open the Arduino IDE and then
click on the Sketch/Import Library menu item. You
should see the storeEEPROM library as shown in
Figure 4. This verifies that you have successfully added
the library to the Arduino directory.
❏ Click on storeEEPROM; it will add #include
■ FIGURE 4: Import
<storeEEPROM.h> to your source code as shown in
Figure 5. You are now ready to write code that will use
the Time library. Note that you aren't required to use
this technique to add the header. You can manually
type it in yourself, but importing it as discussed above
proves that it is in the correct location for the Arduino
IDE to find it.
❏ Open the File/Examples/storeEEPROM/Examples
/storeEEPROM_test as shown in Figure 6. This file
records an int and a long (16-bit and 32-bit data types)
into the eight-bit EEPROM and then reads them back to
verify that the library functions work as advertised.
❏ The source code from the example is as follows:
Serial.println("storeEEPROM library test rev
// test int
Serial.println("Store int 12345 at address
■ FIGURE 6: A101_
Serial.println("Retrieve int from address 0");
int myInt = retrieveIntEEPROM(0);
// test long
Serial.println("Store long 1234567890 at
■ FIGURE 5: Add storeEEPROM header.
Serial.println("Retrieve uint32_t from address
long myLongInt = retrieveLongEEPROM(2);
// do nothing
❏ Compile and upload the code.
❏ Open the serial monitor and verify that you see the
results shown in Figure 7.
Lab 3: Store Calibration Data
■ FIGURE 7: Store and
retrieve EEPROM data.
In Lab 3 of Chapter 7, we built a potentiometer dial
that let us sense angles from zero to 180 that were set by
rotating the potentiometer and reading the resulting
voltage with the Arduino ADC. In that lab, we had to
56 January 2015