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.
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.