#define LED 12
#define BTN 4
#define C_TIME 1000000
void IRAM_ATTR trigger_led(){
digitalWrite(LED,!digitalRead(LED));
}
hw_timer_t*My_timer = NULL;
void setup() {
pinMode(LED,OUTPUT);
pinMode(BTN,INPUT_PULLUP); // put your setup code here, to run once:
attachInterrupt(BTN,trigger_led,RISING);
Serial.begin(115200);
Serial.println("Hello, ESP32-S2!");
My_timer = timerBegin(0,80,true);
timerAttachInterrupt(My_timer, &trigger_led,true);
timerAlarmWrite(My_timer,C_TIME,true);
timerAlarmEnable(My_timer);
}
void loop() {
delay(100);
// put your main code here, to run repeatedly:
// this speeds up the simulation
}
Loading
esp32-s2-devkitm-1
esp32-s2-devkitm-1