Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By Mulson8266
#54462 Hi,

I want to connect 2 magnetic reed sensors to my yellow board esp-12E, but only one sensor works. On two GPIO pins I set input pullup and it works only on gpio2. Below i shows a part of my code.

Code: Select allvoid setup() {
  Serial.begin(115200);
  Serial.println();

  pinMode(2, INPUT_PULLUP);
  pinMode(12, INPUT_PULLUP);
}

void loop() {
  int x;
  int x1;
  if (digitalRead(2) == HIGH) {
    x = 1;
  }
  else {
    x = 0;
  }
  if (digitalRead(12) == HIGH) {
    x1 = 1;
  }
  else {
    x1 = 0;
  }
}


What am i doing wrong? Only one gpio pin can works in input_pullup mode?