#include <EEPROM.h> // Library
const int buttonPin = 2;
int buttonState = 0;
int count = 0;
void setup() {
Serial.begin(9600);
pinMode(buttonPin, INPUT_PULLDOWN);
EEPROM.begin(64); // Begin EEPROM
count = EEPROM.read(1); // Read count from EEPROM address 1
Serial.print("Starting Count is "); // Print String
Serial.println(count); // Print Count Value
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
count++;
EEPROM.write(1, count); // Write Updated Value in EEPROM Address 1
EEPROM.commit(); // Update in Flash
Serial.print("Current order count: ");
Serial.println(count);
delay(100);
while (digitalRead(buttonPin) == HIGH)
;
delay(500);
}
}