Freescale MPR121

Second generation capacitance detection sensor controller. Includes increased electrode count, configurable I2C address, filtering system with debounce, independent electrodes, auto-configuration built in.

Hello World

Import programMPR121_HelloWorld

Test program for capacitive sensing using the Freescale MPR121 on the Sparkfun SEN-10250 BoB

Library

Import libraryMPR121

A device driver for the Freescale MPR121 capactive touch IC. Not optimized for any particular system, just a starting point to get the chip up in running in no time. Changes to registers init() method will tailor the library for end system use.

Pinout

Datasheet

http://cache.freescale.com/files/sensors/doc/data_sheet/MPR121.pdf

Notes

Information

Must add pull-ups to the I2C bus!!

Sparkfun has breakout boards for this device.

Platforms Tested:

Example

Import program

00001 #include "mbed.h"
00002 #include "MPR121.h"
00003 
00004 Serial pc(USBTX, USBRX);
00005 DigitalOut myled(LED1);
00006 
00007 #if defined TARGET_LPC1768 || TARGET_LPC11U24
00008   I2C i2c(p28, p27);
00009   InterruptIn irq(p26);
00010   MPR121 touch_pad(i2c, irq, MPR121::ADDR_VSS);
00011 
00012 #elif defined TARGET_KL25Z
00013   I2C i2c(PTC9, PTC8);
00014   InterruptIn irq(PTA5);
00015   MPR121 touch_pad(i2c, irq, MPR121::ADDR_VSS);
00016 
00017 #else
00018   #error TARGET NOT TESTED
00019 #endif
00020 
00021 int main() 
00022 {       
00023     touch_pad.init();
00024     touch_pad.enable();
00025     touch_pad.registerDump(pc);
00026     
00027     while(1)
00028     {
00029         if(touch_pad.isPressed())
00030         {
00031             uint16_t button_val = touch_pad.buttonPressed();
00032             printf("button = 0x%04x\n", button_val);
00033             myled = (button_val>0) ? 1 : 0;
00034         }            
00035     }
00036 }

Import programtest_DEV-10508

SparkFun touch shield DEV010508


Please log in to start a discussion or ask a question.

Questions