Arduino


SUBMITTED BY: Guest

DATE: July 30, 2014, 11:58 a.m.

FORMAT: Text only

SIZE: 759 Bytes

HITS: 8930

  1. #include <avr/eeprom.h>
  2. const int buttonPin = 2;
  3. int buttonState = 0;
  4. struct settings_t
  5. {
  6. long alarm;
  7. int mode;
  8. } settings;
  9. void setup()
  10. {
  11. eeprom_read_block((void*)&settings, (void*)0, sizeof(settings));
  12. // ...
  13. }
  14. void loop()
  15. {
  16. buttonState = digitalRead(buttonPin);
  17. // let the user adjust their alarm settings
  18. // let the user adjust their mode settings
  19. // ...
  20. settings.mode = analogRead(A0); // potentiometer on A0
  21. // if they push the "Save" button, save their configuration
  22. if (buttonState == HIGH) // button attached on digital pin 2
  23. eeprom_write_block((const void*)&settings, (void*)0, sizeof(settings));
  24. }

comments powered by Disqus