Datasheet
Once the example is running open the serial REPL for your board. With your finger try pressing any of the 0-11 input
pins on the MPR121. You should see a message printed every time an input is touched:
If you don't see any messages when you touch the inputs you might need to ground yourself to the board by touching
the GND pin on the board with one finger and then touching the input pads with another finger.
Also make sure nothing is touching the pins when you first run the script or else it might confuse the MPR121's touch
detection (unmount the board's file system from your operating system, then press the board's reset button to reset the
script and run it again with nothing touching the pins).
Usage
Examine the simpletest.py code to see how to use the MPR121 module. First the module is imported with code like:
# Simple test of the MPR121 capacitive touch sensor library.
# Will print out a message when any of the 12 capacitive touch inputs of the
# board are touched. Open the serial REPL after running to see the output.
# Author: Tony DiCola
import time
# Import MPR121 module.
import adafruit_mpr121
import busio
# Create I2C bus.
import board
i2c = busio.I2C(board.SCL, board.SDA)
# Create MPR121 class.
mpr121 = adafruit_mpr121.MPR121(i2c)
# Note you can optionally change the address of the device:
#mpr121 = adafruit_mpr121.MPR121(i2c, address=0x91)
# Loop forever testing each input and printing when they're touched.
while True:
# Loop through all 12 inputs (0-11).
for i in range(12):
# Call is_touched and pass it then number of the input. If it's touched
# it will return True, otherwise it will return False.
if mpr121.is_touched(i):
print('Input {} touched!'.format(i))
time.sleep(0.25) # Small delay to keep from spamming output messages.
© Adafruit Industries
https://learn.adafruit.com/adafruit-mpr121-12-key-capacitive-touch-sensor-breakout-
tutorial
Page 19 of 24