Hey there!
I got a problem with printing the data that i receive from an Arduino. Actual it is a really simple task. But theere is a problem with printing the integers that i sent from the Arduino as integers.
This is what i get in the Processing console:
Actually it should not print 0 0 0 , but other intgers. I don't send any 0. Is there a Problem with the conversion?
ARDUINO CODE:
#include <CapacitiveSensor.h>
CapacitiveSensor sensor1 = CapacitiveSensor(4,2);
void setup(){ Serial.begin(57600); }
void loop(){ int sens = sensor1.capacitiveSensor(5); Serial.println(sens); // prints value between 10 and 25 }
PROCESSING CODE import processing.serial.*;
Serial myPort; // The serial port
void setup () { // set the window size: size(400, 300); // List all the available serial ports println(Serial.list()); myPort = new Serial(this, Serial.list()[0], 9600); // don't generate a serialEvent() unless you get a newline character: myPort.bufferUntil('\n'); }
void draw () { // everything happens in the serialEvent() }
void serialEvent (Serial myPort) { // get the ASCII string: String inString = myPort.readStringUntil('\n');
if (inString != null) { // trim off any whitespace: inString = trim(inString); // convert to an int int inByte = int(inString); println(inByte); } }