-->
Page 1 of 1

Many magnetic reed sensors on esp8266

PostPosted: Sun Sep 04, 2016 2:15 pm
by Mulson8266
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?