How to store the count value to EEPROM

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// set up a constant for the tilt switchPin
const int switchPin = 6;

int hits = 0;

// variable to hold the value of the switchPin
int switchState = 0;

// variable to hold previous value of the switchpin
int prevSwitchState = 0;

void setup() {
// set up the number of columns and rows on the LCD
lcd.begin(16, 2);

// set up the switch pin as an input
pinMode(switchPin,INPUT);

lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Hit the Switch”);
lcd.setCursor(0, 1);
lcd.print(“to increment the counter”);
}

void loop() {
// check the status of the switch
switchState = digitalRead(switchPin);

// compare the switchState to its previous state
if (switchState != prevSwitchState) {
if (switchState == LOW) {
hits = hits + 1;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Hits:”);
lcd.setCursor(0, 1);
lcd.print(hits);
}
}
// save the current switch state as the last state
prevSwitchState = switchState;
}

Benup113:

is this a demo or a question?

BulldogLowell:
is this a demo or a question?

I think it’s a question, as I don’t see anywhere that he writes to EEPROM.

@Benup113: Please read the post by Nick Gammon at the top of this Forum on the proper way to use this Forum, especially the use of code tags for posting source code.

econjack:
I think it's a question, as I don't see anywhere that he writes to EEPROM.

facetious

econjack:
@Benup113: Please read the post by Nick Gammon at the top of this Forum on the proper way to use this Forum, especially the use of code tags for posting source code.

and the always popular... stating your question!

I guess the question is in the title :wink:

@OP: eeprom reference; put and get is probably what you're looking for for easy of use.