Go Down

Topic: Serial communication with processing [SOLVED] (Read 1 time) previous topic - next topic


May 02, 2013, 12:40 am Last Edit: May 02, 2013, 02:16 am by fxmech Reason: 1
Please help...been stumped all day...

I am sending data to arduino from processing in the form of "+a123"

where + just tells the arduino that data is behind it the a is a command and 123 is any integer value.

I have a GUI in processing with multiple sliders and each slider has a letter assigned (hence the "a") and the value of the slider is the integer behind the letter.

I am sending it out using lines like this using 9600 baud:


on the arduino end I receive it using:

if (Serial.available() > 0){
  inByte = Serial.read();
   // only input if a letter, number, =,?,+ are typed!
   if ((inByte >= 65 && inByte <= 90) || (inByte >=97 && inByte <=122) || (inByte >= 48 &&     inByte <=57) || inByte == 43 || inByte == 61 || inByte == 63) {
}// end serial.available
if (inByte == 10 || inByte == 13){
inByte = 0;
if(command.indexOf('+') == 0){

code = command.substring(1,2);
temp2 = command.substring(2);
value = atoi(carray);

if (code=="c"){  DO SOMETHING with value temp1}

The code is to control RGB LEDs with a processing GUI console.

I'll gladly post the whole code but I thought it would just make it harder to solve this.

Basically if I open up the serial monitor in arduino and type in commands such as +a123 followed by [ENTER]

My leds ramp up the red value to 123.

It works perfectly.

When I println the variables in processing..  the display shows good numbers...

When I connect the arduino to processing.... the sliders don't work with the leds

I am thinking the issue is in how I am sending data to arduino since its mixed letters and integer values but im not sure.  Since I cant open up the serial monitors while the arduino is connected to the com port, I am stuck and completely blind....

Any ideas?????


Just solved it... was missing that invisible CR...
added a myPort.write(13); and it works great now!!!

Go Up