#define LED 5
#define btn 4
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(LED,OUTPUT);
pinMode(btn,INPUT);
}
void Blink_LED(){
for(int i=0;i<5;i++){
digitalWrite(LED,HIGH);
delay(500);
digitalWrite(LED,LOW);
delay(500);
}
}
void loop() {
bool ReadSwitch = digitalRead(btn);
if(ReadSwitch==LOW){
Serial.println("Pressed switch");
Blink_LED();
}
}
Loading
esp32-devkit-c-v4
esp32-devkit-c-v4