0
votes

I want to sent a string from processing to arduino. but the arduino does not receive any data from serial... see below for the processing code:

import processing.serial.*;
Serial myPort;

void setup(){
    String portName = Serial.list()[2];
    myPort = new Serial(this, portName, 9600);
}

void draw(){

    myPort.write(parseRed + " | " + parseGreen + " | " + parseBlue);

}

see here my arduino code:

String serialData;

String serialDataRed;
String serialDataGreen;
String serialDataBlue;

void setup(){
   Serial.begin(9600);

}

void loop(){

   if (Serial.available()) {
      serialData = Serial.readString();

      serialDataRed = serialData.substring(0, 5);
      serialDataGreen = serialData.substring(9, 16);
      serialDataBlue = serialData.substring(20, 26);
   }

}

when I run this script nothing happens arduino doesn’t see to receive any data... can someone tell me what I am doing wrong??

1
What is parseRed, parseGreen, and parseBlue? Where are they defined and what are their values? Does the Arduino loop() function ever get called? Does it enter that if statement? You'll have better luck if you post a minimal reproducible example and tell us the debugging steps you've already done.Kevin Workman
parseRed, parseGreen, parseBlue are strings. they look like the following: "minRed" or "neuGreen" or "maxBlue" and so on. and yes the loop() function does get called because it is the same as the draw() function in processing.FutureCake
But how do you know it's actually being called? Have you done any debugging to guarantee that's the case? You have to narrow down the problem to a specific place where the code's actual execution differs from what you expect. We can't really help with that unless you post a minimal reproducible example that shows the code you're actually running.Kevin Workman

1 Answers

0
votes

well i found my error :D kinda a stupid mistake dough...

String portName = Serial.list()[2];

should be:

String portName = Serial.list()[3];

because my arduino was connected to a different usb port then before... so the lesson is: check if you are using the right port... thank you kevin for the help dough :)