Capacitive Keypad

Z2M Part: EMS-016-A

I2C capacitive touch keypad for input detection.

Circuit Diagram
Circuit diagram for Capacitive Keypad
Wire Connections & Pin Configuration

Wire Color Connections:

Red → 5V to Keypad VCC
Black → GND to Keypad GND
Green → A4 (SDA) to Keypad SDA
Blue → A5 (SCL) to Keypad SCL

Pin Configuration:

Arduino 5V → Capacitive Keypad VCC
Arduino GND → Capacitive Keypad GND
Arduino SDA (A4) → Capacitive Keypad SDA pin
Arduino SCL (A5) → Capacitive Keypad SCL pin
Arduino Code
Edit
#include <Wire.h>

#define KEYPAD_I2C_ADDR 0x57  // TTP229-I2C default address (use I2C scanner if different)

byte keyPressed = 0;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  Serial.println(\"Capacitive Keypad (I2C) Ready. Press a key...\");
}

void loop() {
  Wire.requestFrom(KEYPAD_I2C_ADDR, (uint8_t)2);
  if (Wire.available() >= 2) {
    uint16_t keyData = Wire.read() | (Wire.read() << 8);
    for (byte i = 1; i <= 16; i++) {
      if (keyData & (1 << (i - 1))) {
        keyPressed = i;
        Serial.print(\"Key Pressed: \");
        Serial.println(keyPressed);
        break;
      }
    }
  }
  delay(100);
}

Instruction Details

Wiring: Connect keypad VCC to 5V, GND to GND, SDA to Arduino A4, SCL to Arduino A5.
Library: Not required (built-in Wire library).
Upload Code: Tools → Board → Arduino Uno. Tools → Port → select your COM port. Click Upload button.
View Output: Open Serial Monitor (Tools → Serial Monitor) at 9600 baud. Press keys to see key number displayed. Use I2C scanner if address differs from 0x57.

How to Use

  1. Connect the required components as per the Pin Configuration above
  2. Open Arduino IDE and create a new sketch
  3. Copy and paste the code above
  4. Select your Arduino board and COM port from Tools menu
  5. Click the Upload button to upload the code to your Arduino
  6. Open Serial Monitor (if applicable) to see the output

Components Required

  • Arduino Uno
  • Capacitive Touch Keypad (I2C, e.g. TTP229-I2C)
  • Breadboard
  • Jumper Wires

Category: Arduino Basics