nothing received null
Did your arduino send anything? Arduino and Processing have to be paired. What one side is programmed to send, the other side has to be programmed to receive.
You mentioned testing the ‘blink’ example in Arduino. Try using this set of code, one set for the arduino to receive and light up a LED on your arduino board and the Processing app to repeatedly send a zero or a one: zero = turn LED off, one = turn LED on.
Processing send:
import processing.serial.*;
Serial myPort;
void setup() {
// List all the available serial ports:
printArray(Serial.list());
// Open the port you are using at the rate you want:
myPort = new Serial(this, Serial.list()[7], 9600);
}
void draw() {
myPort.write(1); // turn on led
delay(1000);
myPort.write(0); // turn off led
delay(1000);
}
Arduino receive:
int incomingByte = 0; // for incoming serial data
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
delay(2500);
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
switch (incomingByte) {
case 0 : digitalWrite(LED_BUILTIN, LOW);
break;
case 1 : digitalWrite(LED_BUILTIN, HIGH);;
break;
default: Serial.println("something else");
}
}
}