//#define btn 21
int btn = LOW;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(21, INPUT);
pinMode(17, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int btn = digitalRead(21);
if (btn==1)
{
digitalWrite(17, HIGH);
Serial.println("Button is pressed");
//delay(1000);
}
else
{
digitalWrite(17, LOW);
Serial.println("Button is Released");
}
delay(10); // this speeds up the simulation
}
/**
#define BUTTON_PIN 21
#define LED_PIN 17
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(BUTTON_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int btn = digitalRead(BUTTON_PIN);
if (btn == HIGH) {
digitalWrite(LED_PIN, HIGH);
Serial.println("Button is pressed");
} else {
digitalWrite(LED_PIN, LOW);
Serial.println("Button is released");
}
delay(10); // this speeds up the simulation
}
**/