Created
January 12, 2016 14:40
-
-
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.
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 | |
#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