Add uOLED-96-G1 C Sample Code.
[frickel.git] / projects / geeknamensschilder_c / hardware / libraries / EEPROM / examples / eeprom_write / eeprom_write.pde
blobae7c57ebd4f70aef02f718614419bba1f3170d0e
1 /*
2  * EEPROM Write
3  *
4  * Stores values read from analog input 0 into the EEPROM.
5  * These values will stay in the EEPROM when the board is
6  * turned off and may be retrieved later by another sketch.
7  */
9 #include <EEPROM.h>
11 // the current address in the EEPROM (i.e. which byte
12 // we're going to write to next)
13 int addr = 0;
15 void setup()
19 void loop()
21   // need to divide by 4 because analog inputs range from
22   // 0 to 1023 and each byte of the EEPROM can only hold a
23   // value from 0 to 255.
24   int val = analogRead(0) / 4;
25   
26   // write the value to the appropriate byte of the EEPROM.
27   // these values will remain there when the board is
28   // turned off.
29   EEPROM.write(addr, val);
30   
31   // advance to the next address.  there are 512 bytes in 
32   // the EEPROM, so go back to 0 when we hit 512.
33   addr = addr + 1;
34   if (addr == 512)
35     addr = 0;
36   
37   delay(100);