
// Section E
// Electrode Configuration
// Enable 6 Electrodes and set to run mode
// Set ELE_CFG to 0x00 to return to standby mode
mpr121Write(ELE_CFG, 0x0C); // Enables all 12 Electrodes
//mpr121Write(ELE_CFG, 0x06); // Enable first 6 electrod
es
// Section F
// Enable Auto Config and auto Reconfig
/*mpr121Write(ATO_CFG0, 0x0B);
mpr121Write(ATO_CFGU, 0xC9); // USL = (Vdd
0.7)/vdd*256 = 0
xC9 @3.3V mpr121Write(ATO_CFGL, 0x82); // LSL = 0.65*USL =
0x82 @3.3V
mpr121Write(ATO_CFGT, 0xB5);*/
// Target = 0.9*USL = 0xB
5 @3.3V
}
The final section of the sketch simply reads the IRQ pin for an indication
that an electrode has been pressed. It then returns either a 1 or 0 as the
value for
checkInterrupt()
variable.
byte checkInterrupt(void)
{
if(digitalRead(irqpin))
return 1;
return 0;
}
Now that you know how the keypad works and communicates with the
Arduino, you can start customizing your project and going further.
Resources and Going Further
Now that you’ve figured out how to use the various versions of the MPR121
IC, what kind of cool projects can you come up with? If you have any
questions still, check out the additional resources below, or feel free to
leave a comment on the tutorial.
Resources
• Example Code
• MPR121 Datasheet
• Breakout Board Schematic
• Breakout Board Eagle Files
Page 23 of 24