ESP-01 TX Button and RX LED Example


 

This example reads a push button connected to GPIO1 (TX) and controls an LED connected to GPIO3 (RX).

 
 

void setup() {
  pinMode(1, INPUT_PULLUP);  
  pinMode(3, OUTPUT);        
}

void loop() {
  
  int buttonState1 = digitalRead(1);  

  if (buttonState1 == LOW) digitalWrite(3, HIGH);            
  else { digitalWrite(3, LOW); }

  delay(50);  

}


 

When the button is pressed, the LED connected to the RX pin turns on.

 

TX button RX LED circuit 


ESP01
ESP01S