Skip to content

Instantly share code, notes, and snippets.

@unknowndomain
Created January 12, 2016 14:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unknowndomain/66d566eb655fc3ebdd4f to your computer and use it in GitHub Desktop.
Save unknowndomain/66d566eb655fc3ebdd4f to your computer and use it in GitHub Desktop.
Uses https://github.com/BareConductive/mpr121 library to output electrode values in CSV or other delimited value format.
#include <MPR121.h>
#include <Wire.h>
#define numElectrodes 12
#define DELIMITER ","
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();
// Loop through all electrodes
for ( int i = 0; i < numElectrodes; i++ ) {
// Print current touch status of electrode
Serial.print( MPR121.getTouchData( i ) );
// Print delimiter between each value
if ( ( i + 1 ) < numElectrodes ) {
Serial.print( DELIMITER );
}
}
// Print new line at after all values output
Serial.println();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment