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??
parseRed
,parseGreen
, andparseBlue
? Where are they defined and what are their values? Does the Arduinoloop()
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