#define LED_PIN 26
#define BUTTON_PIN 27
#define V_PIN 4
double t;
bool on;
volatile bool a = false;
IRAM_ATTR void ISRled(){
a = true;
}
void setup() {
t=0.0;
on= false;
Serial.begin(115200);
pinMode(LED_PIN, OUTPUT);
pinMode(BUTTON_PIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(BUTTON_PIN), ISRled, FALLING);
}
void loop() {
double frecuencia = 1/((millis()-t)/1e3);
Serial.print("Frecuencia: ");
Serial.println(frecuencia);
Serial.println(analogRead(V_PIN));
if(a)
{
digitalWrite(LED_PIN, on);
on = !on;
}
t=millis();
a=false;
delay(50); // this speeds up the simulation
}