Noob question: serial input with Processing

I have a feeling I'm doing something silly here.

Trying to read a rotary pot with Arduino and send the data to Processing. The Arduino serial monitor displays lovely integers exactly as I expect, however when I try to read from the same serial port in Processing, all I see is 0's.

This happens whether I close Arduino + the serial monitor or not. However I've noticed when I run the Processing sketch without closing the serial monitor it throws up junk characters:


But still zeroes in the Processing output window.

The sketches are simplified versions of the AnalogInput/SimpleRead examples in Arduino/Processing respectively - sorry but I couldn't copy the code in forum format for some reason.


int sensorPin = 2;    // select the input pin for the potentiometer
int ledPin = 13;      // select the pin for the LED
int sensorValue = 0;  // variable to store the value coming from the sensor

void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);  

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);    



import processing.serial.*;

Serial myPort;  // Create object from Serial class
int val;      // Data received from the serial port

void setup() 
 //size(200, 200);
  // I know that the first port in the serial list on my mac
  // is always my  FTDI adaptor, so I open Serial.list()[0].
  // On Windows machines, this generally opens COM1.
  // Open whatever port is the one you're using.
  //String portName = Serial.list()[2];
  String portName = "/dev/cu.usbserial-A7006Qyj";
  myPort = new Serial(this, portName, 38400);

void draw()

I have a feeling I'm doing something silly here.

Yep, you are.

Imagine that the serial data is like e-mail The Arduino carefully hunt-and-pecks out a brilliant missive, and hits send.

The Processing sketch then fails to read that e-mail, but tries to print out what it read.

Somewhere in the Processing code, you actually need to read the serial data. I think that when you simplified the Processing example, you deleted too much. Better start over.