I have programmed my UNO witch the sketch as in the attach, an up-down counter.
But...I want to save the last value (figure) on the display after switching off the power.
So the last figure appears when I switch on again.
There is an EEPROM in the examples and I tried this sketch to implement in the up-down counter program, but it does not work ....
Can anybody help me to get this done.
Sorry to say, but I am not a ICTer , so please keep the answer simple
Thanks for reading
greeitings
Bouke
zhtech@kpnmail.nl
www.zhtech.nl
// 2 switches to make a count increment and decrement
byte* const EEADR = 0;
const byte sw1 = 8;Â // Connect pin 8 to SW1
const byte sw2 = 9;Â // Connect pin 9 to SW2
int count = 0;
#include <LiquidCrystal.h>
// instanciate to RS Enable D4 D5 D6 D7
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
void setup()
{
 // set up the LCD's number of columns and rows:
 lcd.begin(16, 2);
 // Print a message to the LCD.
 lcd.print(F("Up-Down Counter"));
 // Declare Switches as INPUT to Arduino
 pinMode(sw1, INPUT_PULLUP);
 pinMode(sw2, INPUT_PULLUP);
 Serial.begin(9600); // communicatie met PC
 count = eeprom_read_byte(EEADR+1);
 count <<= 8;
 count |= eeprom_read_byte(EEADR);
}
void loop()
{
 bool changed = false;
 if (digitalRead(sw1) == LOW) // if SW1 is pressed perform action described in loop
 {
  changed = true;
  count++;          // Increment Count by 1
  lcd.setCursor(0, 1);
  lcd.print(count);
  delay(100);
 }
 if (digitalRead(sw2) == LOW) // if SW2 is pressed perform action described in loop
 {
  changed = true;
  count--;          // Decrement Count by 1
  if (count < 0)
   count = 0;
  lcd.setCursor(0, 1);
  lcd.print(count);
  delay(100);
 }
 if (changed) {
  if (eeprom_read_byte(EEADR) != (byte)count) {
   eeprom_write_byte(EEADR, (byte)count);
  }
  if (eeprom_read_byte(EEADR + 1) != (byte)(count >> 8)) {
   eeprom_write_byte(EEADR + 1, (byte)(count >> 8));
  }
 }
}