Capacitive Touch

edited March 2016 in Arduino

I have conductive paint which works in an arduino using the capacitive touch library and when its touched i get a reading between 50 and 60 in the serial port. however i need to get the conductive paint sensor working in processing but i am having difficulty as the only output i get in processing is null and i am looking for help as to what i am doing wrong or if there is any simpler ways of going about this. I am very new to this but am desperate to get this working

code for arduino:

include <CapacitiveSensor.h>

CapacitiveSensor cs_2_4 = CapacitiveSensor(2,4);
void setup()
{

Serial.begin(9600); }

void loop()
{ long start = millis(); long total5 = cs_2_4.capacitiveSensor(30);

Serial.print(millis() - start);        // check on performance in milliseconds
Serial.print("\t");                    // tab character for debug windown spacing

Serial.println(total5);                  // print sensor output 1

            // print sensor output 3

delay(10);                             // arbitrary delay to limit data to serial port

}

code for processing:

import processing.serial.*;

Serial myPort; // Create object from Serial class

String val; // Data received from the serial port

void setup() { size(400,400); myPort = new Serial(this, Serial.list()[0], 9600); }

void draw()

{ if ( myPort.available() > 0)

{ // If data is available, val = myPort.readStringUntil('\n'); // read it and store it in val }

println(val); //print it out in the console }

Answers

This discussion has been closed.