Skip to content

Instantly share code, notes, and snippets.

Created October 1, 2014 18:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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
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(",");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment