We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello, I'm trying to use a capacitive sensor on arduino as an input to then have processing draw a chart with data or just write a text according to values gotten by the sensors. So far I've been able to read the values on the processing screen, but can't make processing write a text if the value goes over 300 for example...
The Arduino code is:
CapacitiveSensor capSensor7 = CapacitiveSensor(13, 7); CapacitiveSensor capSensor8 = CapacitiveSensor(13, 8); CapacitiveSensor capSensor9 = CapacitiveSensor(13, 9);
void setup() { // open a serial connection Serial.begin(9600); }
void loop() { long sensorValue7 = capSensor7.capacitiveSensor(10); long sensorValue8 = capSensor8.capacitiveSensor(10); long sensorValue9 = capSensor9.capacitiveSensor(10);
delay (300); Serial.print("\t Lata3: "); Serial.print(sensorValue7);
Serial.print("\t Lata2: "); Serial.print(sensorValue8);
Serial.print("\t Lata1: "); Serial.println(sensorValue9);
}
And the processing code is: import processing.serial.*;
Serial myPort; // Create object from Serial class String val; // Data received from the serial port
void setup(){ String portName = Serial.list()[0]; //change the 0 to a 1 or 2 etc. to match your port myPort = new Serial(this, portName, 9600); }
void draw() {
frameRate (9);
if ( myPort.available() > 0) {
val = myPort.readStringUntil('\n'); // read it and store it in val
}
println(val); //print it out in the console
}
Help please!!
Answers
http://forum.processing.org/two/discussion/8045/how-to-format-code-and-text