

The Adafruit MPR121 is a capacitive touch sensor module that features the MPR121 touch controller IC. It is designed to detect electrical changes on its 12 input pins that occur when a touch or proximity event is detected. This module is commonly used in creating touch interfaces, adding touch buttons to electronic projects, and in applications requiring user input without mechanical buttons.








| Pin Number | Name | Description |
|---|---|---|
| 1 | VIN | Supply voltage (2.5V to 3.6V) |
| 2 | 3Vo | 3.3V output from the onboard regulator |
| 3 | GND | Ground connection |
| 4 | SDA | I2C data line |
| 5 | SCL | I2C clock line |
| 6 | IRQ | Interrupt output (active low) |
| 7-18 | 0-11 | Capacitive touch input pins |
#include <Wire.h>
#include <Adafruit_MPR121.h>
// You can have up to 4 on one i2c bus (connecting ADDR to 3V,
// setting the jumpers to different combinations of connecting them to ground)
Adafruit_MPR121 cap = Adafruit_MPR121();
void setup() {
Serial.begin(9600);
while (!Serial) { // Needed to start serial on some platforms
delay(10);
}
if (!cap.begin(0x5A)) {
Serial.println("MPR121 not found, check wiring?");
while (1);
}
Serial.println("MPR121 found!");
}
void loop() {
// Get the currently touched pads
currtouched = cap.touched();
for (uint8_t i=0; i<12; i++) {
// it if *is* touched and *wasnt* touched before, alert!
if ((currtouched & _BV(i)) && !(lasttouched & _BV(i)) ) {
Serial.print(i); Serial.println(" touched");
}
// if it *was* touched and now *isnt*, alert!
if (!(currtouched & _BV(i)) && (lasttouched & _BV(i)) ) {
Serial.print(i); Serial.println(" released");
}
}
// reset our state
lasttouched = currtouched;
// comment out this line for detailed data from the sensor!
delay(100);
}
Q: Can I use the MPR121 with a 5V microcontroller? A: Yes, but ensure that the MPR121 module is powered with a voltage within its operating range (2.5V to 3.6V). Use level shifters if necessary for the I2C lines.
Q: How can I change the sensitivity of the touch inputs? A: Sensitivity can be adjusted by writing to the MPR121's internal registers. Refer to the MPR121 datasheet for detailed register settings.
Q: How many MPR121 modules can I connect to a single I2C bus? A: You can connect up to 4 MPR121 modules to a single I2C bus by setting different I2C addresses using the address jumpers on the back of the module.