#include <Adafruit_TCA8418.h>
Adafruit_TCA8418 keypad;
void setup()
{
Wire.begin(D2, D3);
Serial.begin(115200);
while (!Serial) {
delay(10);
}
if (! keypad.begin(TCA8418_DEFAULT_ADDR, &Wire)) {
Serial.println("keypad not found, check wiring & pullups!");
while (1);
}
// configure the size of the keypad matrix.
// all other pins will be inputs
keypad.matrix(8, 10);
// flush the internal buffer
keypad.flush();
}
void loop()
{
if (keypad.available() > 0)
{
// datasheet page 15 - Table 1
int k = keypad.getEvent();
if (k & 0x80) Serial.print("PRESS\tR: ");
else Serial.print("RELEASE\tR: ");
k &= 0x7F;
k--;
Serial.print(k / 10);
Serial.print("\tC: ");
Serial.print(k % 10);
Serial.println();
}
// other code here
}Loading
xiao-esp32-c6
xiao-esp32-c6
Box
Lid
Box
Lid