Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Arduino Capsense Code
//import the capSense Library
#include <CapacitiveSensor.h>
//these are the capsense inputs 2 is the common send the second number is the
//other digital input the sensor is attached to
CapacitiveSensor cs_2_3 = CapacitiveSensor(2,3);
void setup() {
//Begin Serial Communication with a baud rate of 9600
//this must match the serial that you enter into processing/OF
Serial.begin(9600);
}
void loop() {
// Store the value input of each sensor in each of these variables
long CapSense1 = cs_2_3.capacitiveSensor(30);
/*The Serial.print() doesn't have a space
the ',' is used to parse the values in processing
the last value does not require the ','
but make sure you have a blank Serial.println(); follwoing it*/
// put into DEC form for parsing in processing
//this is how you will get processing to read you sensor inputs and split them up!
long mapCap = map(CapSense1, 0, 900, 0, 10);
Serial.print(mapCap, DEC);Serial.print(",");
Serial.println();
delay(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.