ESP32 – Digital Button

About two years ago I was at a code conference and was given an ESP8266. To be honest, I had no idea what it was nor it’s capabilities at the time. When I got home, I put it in a box in my lab and forgot about it. Fast forward a year and I discovered the ESP32 due to some shortcomings with Arduino. Funnily enough, I remembered that I had that ESP8266 and laughed to myself that I had been sitting on my solutions without ever knowing it 🙂

Anyway, I’ve decided to start deep diving into ESP32 more and really trying to see what it’s capable of as per my needs. So these upcoming post albeit simplistic in nature is nothing more than me experimenting and posting for the sake of posterity, for now.

As my endeavors take me deeper into IOT we’ll see where this goes eventually.

That said, what we have here is nothing more than your run of the mill push button drives LED off an IO port.

const byte LED_GPIO = 32;
const byte BUTTON_GPIO = 36;

int buttonState = 0;

void setup() 
  //initialization of GPIO pin as output
  pinMode(LED_GPIO, OUTPUT);

  //initialization of Button as input

void loop() 
  //read state of the button
  buttonState = digitalRead(BUTTON_GPIO);

  if (buttonState == HIGH)
    digitalWrite(LED_GPIO, HIGH);
    digitalWrite(LED_GPIO, LOW);


Leave a Reply

Your email address will not be published. Required fields are marked *