The following two sets of code for Arduino and Processing works on my Mac:
ARDUINO
void setup() {
//initialize serial communications at a 9600 baud rate
Serial.begin(9600);
}
void loop() {
//send ‘Hello, world!’ over the serial port
Serial.println("Hello, world!");
//wait 100 milliseconds so we don’t drive ourselves crazy
delay(100);
}
PROCESSING
import processing.serial.*;
Serial myPort; // Create object from Serial class
String val; // Data received from the serial port
void setup(){
printArray(Serial.list());
String portName = Serial.list()[3]; //change the 0 to a 1 or 2 etc. to match your port
println("portName = " + portName);
myPort = new Serial(this, portName, 9600);
println("port = " + myPort);
}
void draw(){
if ( myPort.available() > 0) { // If data is available,
// println("port is available: ");
val = myPort.readStringUntil('\n'); // read it and store it in val
println(val);
}
}
Make sure that you print the serial.list so that you can see that you selected the correct port. This port should match what Arduino IDE says it is using to send the data.