EPS8266 Thing will not read GPIO 4

Hello!

I am having a great deal of trouble with the ESP8266 thing reading GPIO 4. I can clearly put 3.3 volts or 0.2 volts on it (LOW)

But for some reason it will not activate anything. Can someone look over this and tell me what I am doing wrong?

Here is the basic code I have been using to test it

#define ESP8266_LED 5
#define READpin 4
int val;

void setup() 
{
  pinMode(ESP8266_LED, OUTPUT);
  pinMode(READpin, INPUT);
  
}

void loop() 
{
  val = digitalRead(READpin);
  if(val == HIGH){
  digitalWrite(ESP8266_LED, HIGH); // LED off
  }
  else{
  digitalWrite(ESP8266_LED, LOW); // LED on
  }
}

The LED will not turn on? I don’t think I shorted or burned the pin out because it looks directly connected to the micro controller.

Thank you

Disregard, you meant the onboard led no doubt.

Don’t wire 3.3 volt or 0 volt supply directly to the pin. If at some point in the code it accidentally get’s activated as an output then it can short out and get damaged. Make sure you have a resistor (1 k ohm or something) in the path to limit the current.

I would add Serial statements to Setup() and Loop() so it sends the measured state of val to the PC. To make sure that the digital pin state is actually registered. In the above code you assume that the digitalRead statement returns different values. I can’t see anything wrong with the code, as it looks so simple. But your experience suggests something is wrong. So I would start to second-guess anything and make it proof that it works.