#include <EEPROM.h>
unsigned char c1 = 1;
unsigned char c2 = 2;
unsigned char c3 = 3;
unsigned char c4 = 4;
#define EEPROM_SIZE 1
const int buttonpin = 23;
const int ledpin = 22;
int ledstate = HIGH;
int butttonState;
int lastbuttonstate = LOW;
unsigned long lastdebouncetime = 0;
unsigned long debouncedelay = 50;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
EEPROM.begin(EEPROM_SIZE);
Serial.println ("EPPROM CONFIGURADA");
pinMode(buttonpin, INPUT);
pinMode(ledpin, OUTPUT);
//leer e; ultimo estado del led
ledstate= EEPROM.read(0);
digitalWrite(ledpin,ledstate);
Serial.println("Hello, ESP32!");
}
void loop() {
int reading = digitalRead(buttonpin);
if (reading != lastbuttonstate){
lastdebouncetime = millis()
}
if((millis()- lastdebouncetime)> debouncedelay){
if (reading! = buttonstate){
buttonstate = reading;
if(buttonstate= HIGH);{
ledstate= !ledstate;
}
}
}
lastbuttonstate =reading;
}