Skip to content

Instantly share code, notes, and snippets.

@LucyMatch LucyMatch/CapSense Arduino
Last active Aug 29, 2015

Embed
What would you like to do?
Arduino Sketch Taking in CapSense Values
//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);
CapacitiveSensor cs_2_4 = CapacitiveSensor(2,4);
CapacitiveSensor cs_2_5 = CapacitiveSensor(2,5);
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);
long CapSense2 = cs_2_4.capacitiveSensor(30);
long CapSense3 = cs_2_5.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!
Serial.print(CapSense1, DEC);Serial.print(",");
Serial.print(CapSense2, DEC);Serial.print(",");
Serial.print(CapSense3, 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.