wuxx / nanoESP32-S2

47 stars 9 forks source link

about pin INPUT_PULLUP problem. #2

Open shownb opened 8 months ago

shownb commented 8 months ago
int8_t col_pins[] = { 1, 2, 4, 6 };

void setup() {
  Serial.begin(115200);

  for (int8_t pin : col_pins) {
    pinMode(pin, INPUT_PULLUP);
  }

}

void loop() {
  for (int8_t col = 0; col < sizeof(col_pins); ++col) {
    bool key_state = digitalRead(col_pins[col]);
    if (key_state==LOW) {
      Serial.printf("LOW");
    }
  }
}

sometimes loose wire will cause the detected voltage to be low. The same code in s3 will not have this problem. I want to use s2 for a matrix keyboard.