The MPR121 Capacitive Touch Sensor Breakout Board is a sophisticated electronic component designed to add touch sensing capabilities to your projects. Utilizing the MPR121 chip, this breakout board can detect the touch or proximity of human fingers and provides a digital output signal for each of its 12 electrodes. Common applications include touch interfaces, interactive installations, and replacement of traditional buttons.
Pin Number | Pin Name | Description |
---|---|---|
1 | IRQ | Interrupt output to microcontroller |
2 | ADDR | I2C address select pin |
3 | SDA | I2C data line |
4 | SCL | I2C clock line |
5 | VDD | Power supply (2.5V to 3.6V) |
6 | GND | Ground |
7-18 | ELE0-ELE11 | Electrode connections for touch inputs |
#include <Wire.h>
#include "Adafruit_MPR121.h"
// You can have up to 4 on one i2c bus (connecting ADDR to 3.3V, GND or leaving it floating)
// but you can only have one sensor per unique i2c address.
Adafruit_MPR121 cap = Adafruit_MPR121();
void setup() {
Serial.begin(9600);
while (!Serial) { // needed to keep leonardo/micro from starting too fast!
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 the MPR121 operate at 5V? A: No, the MPR121 is designed to operate between 2.5V and 3.6V. Using a higher voltage can damage the chip.
Q: How can I change the sensitivity of the touch detection? A: Sensitivity can be adjusted through the MPR121's internal registers. Refer to the datasheet for detailed register settings.
Q: Can I use the MPR121 with a microcontroller other than an Arduino? A: Yes, as long as the microcontroller supports I2C communication, you can interface with the MPR121.
Q: How do I clean the electrodes? A: Use a soft, dry cloth to gently wipe the electrodes. Avoid using any liquids or abrasive materials that could damage the board.
For further assistance, consult the MPR121 datasheet and ensure that your setup matches the recommended configurations.