// Define the pin for the LED
#define LED 21

hw_timer_t *Timer0_Cfg = NULL; // Declare a pointer for Timer configuration

// Interrupt Service Routine (ISR) for Timer0
void IRAM_ATTR Timer0_ISR() {
    digitalWrite(LED, !digitalRead(LED)); // Toggle the LED state
}

void setup() {
    Serial.begin(115200); // Start serial communication
    pinMode(LED, OUTPUT); // Set the LED pin as an output
    
    // Configure Timer0
    Timer0_Cfg = timerBegin(0, 800, true); // Initialize Timer0 with a prescaler of 800 and enable it
    timerAttachInterrupt(Timer0_Cfg, &Timer0_ISR, true); // Attach the ISR to Timer0
    timerAlarmWrite(Timer0_Cfg, 50000, true); // Set the timer's alarm value
    timerAlarmEnable(Timer0_Cfg); // Enable the timer's alarm
}

void loop() {
    int a = digitalRead(LED); // Read the state of the LED pin
    int scaledValue = map(a, LOW, HIGH, 0, 2500); // Map the LED state to a range of 0 to 2500
    
    Serial.println(scaledValue); // Print the scaled value
    delay(100); // Delay for 100 milliseconds
}