Created
May 2, 2017 17:11
-
-
Save unknowndomain/9d7122a5beb44b5b3ebf6c8a4928fdfd to your computer and use it in GitHub Desktop.
Demos how to use the https://github.com/BareConductive/mpr121 library to get touch values and proximity values from each electrode.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <MPR121.h> | |
#include <Wire.h> | |
#define numElectrodes 12 | |
void setup() { | |
Serial.begin( 9600 ); | |
Wire.begin(); | |
// Setup MPR121 | |
MPR121.begin( 0x5A ); | |
MPR121.setInterruptPin( 4 ); | |
MPR121.setTouchThreshold( 40 ); | |
MPR121.setReleaseThreshold( 20 ); | |
} | |
void loop() { | |
// Check for new data | |
MPR121.updateTouchData(); | |
MPR121.updateFilteredData(); | |
// Get an analog proximity value | |
Serial.print( MPR121.getFilteredData( 1 ) ); | |
// Get a touched/not touched value | |
if ( MPR121.getTouchData( 1 ) ) { | |
Serial.println( " - Touching" ); | |
} else { | |
Serial.println( " - Not Touching" ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lovely example 👍