I am trying to have Processing read a file and send the contents to the arduino to use. I have made my script so basic that when the arduino receives anything from the serial port, it will turn on the built in LED. After getting my arduino to wait for serial input and executing my processing script, the tx led flashes on the arduino, the Processing code executes yet the built in LED does not turn on. I have tested my script with arduino's serial monitor and everything works fine, it is only from Processing. I am sure I am connecting to the right port because I have listed the ports, there is only one port and I have also tried putting the port name instead of the index in.
I have tried sending both strings, chars and ints from Processing, I have tried Serial.read(), Serial.readString(), Serial.readByte and quite literally copy/pasting codes that others have said worked for them with nothing able to work. Is there any way to debug without the serial monitor?
Processing code
import processing.serial.*;
Serial myport;
int portindex=0; // Arduino USB port number from the serial list
void setup(){
myport = new Serial(this,Serial.list()[portindex],115200); // Initialize port
// Sending the content of the array
myport.write(1);
}
Arduino code
int data;
char buffer;
String cumBuffer;
byte bytebuffer;
void setup() {
Serial.begin(115200); // Starts serial port
pinMode(LED_BUILTIN, OUTPUT); // on board LED, due = 13
}
void loop() {
if (Serial.available() > 0) {
digitalWrite(13, HIGH);
delay(3000);
bytebuffer = Serial.read(); // Serial.read()-'0';
}
if(bytebuffer==1){
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(500);
}
}