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:
d¤ª¤ªdjdª¤ªdjd¤ª¤ªPªdjddj¤dªj¤dªjPdª
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.
Arduino
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);
Serial.begin(38400);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
Serial.print(sensorValue/8);
Serial.println();
}
Processing
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()
{
println(val);
}