communication with processing messed up

if i test this in processing:

void setup() {
  char t = 'a';
  t = '\0';

  println(t);
}

then it prints nothing, if i comment the t = '\0'; line then it prints 'a' to the console.

So in this part of your code:

         if(index < 19)
         {
            inData[index++] = inChar;
            inData[index] = '\0';
         }

Shouldn't this line: inData[index] = '\0';
not be one line higher? (and then ++ switched afcorse).

And about the interfacing serials, i stripped the processing code to this:

import processing.serial.*;

Serial port;

void setup() {
  frameRate(1);
  println(Serial.list()); 
  port = new Serial(this, Serial.list()[1], 9600);
}

void draw() {
  port.write("[");
  port.write(frameCount);
  port.write("]");
}

my serial monitor output is this:

Received: <>
Receivived: <>
Received: <>
Received: <>
Received: <>
Received: <>
Received: <>
Received: <>
Received: <>
Received: <>

then it prints nothing

When you set t to NULL, it makes it "nothing", so when nothing is printed, that is the expected behavior.

Setting a character to NULL, and setting an element in a character array to NULL have much different results.

Shouldn't this line: inData[index] = '\0';
not be one line higher? (and then ++ switched afcorse).

No, it shouldn't.

The elements in an array are like boxes in a post office. There is one letter in each box. If you open the boxes in order, and read each letter, until you encounter an empty box, you make something of the letters you have read.

The "empty box" is the NULL character in a char array.

What that code is doing is putting a letter in a box, and removing the letter from the next box, saying "stop reading when you get here".

i stripped the processing code to this

my serial monitor output is this:

I'm not sure how many more times I need to say this. There can only be one application on each end of the serial port. The Arduino is on one end. If the serial monitor is on the other end, Processing can not be there, too. So, the Arduino gets no data.

If the Processing application is there, then the Serial Monitor should not be trying to intercept the output.

You can make Processing read the responses from the Arduino. That is the ONLY way that you can debug the communications process.

Until this sinks in, I can't help you any more.

ok got it :slight_smile:
And i used a pot meter for now. I will give it another attempt later.