Hi so I am currently trying to attach some infrared sensors to the Analog In ports of an Uno. I have tested and verified that the circuit works in the normal Arduino software, but I can't seem to get it to work in Processing. Here is the Code:

I have no idea what you are talking about. The analogRead() method returns an int, which you (correctly) store in an int.

That is, it returns an int IF communication with the Arduino was successful. Otherwise, it returns a 0.

That you consistently get 0, but not when using the serial monitor and a different sketch, implies that either the wrong sketch is loaded on the Arduino OR that your Arduino is not connected to the first serial port in the list.

You have commented out the line that prints the list of serial ports. Are you POSITIVE that the Arduino is connected to the first port?

I used COM3 on the basis that in Arduino, it says Arduino Uno on COM3 so I assumed that was what I should use. I am starting to think, however, that might not be the case since I get the same message without the Uno plugged in.

Here is a processing sketch I found on the web that creates a bar graph based on serial input from your arduino. The Arduino must send a byte with a value of 0 to 255. Run the sketch and look at the text in the area that reports errors, that will tell you what number goes in this part:

Hi so I am currently trying to attach some infrared sensors to the Analog In ports of an Uno. I have tested and verified that the circuit works in the normal Arduino software, but I can't seem to get it to work in Processing.

That's because that Processing sketch expects you to be running one of the Firmata sketches.

The second bit of code I posted was used in Arduino 1.0. I have been playing around with the code and I've found this:

// Example by Tom Igoe

import processing.serial.*;

Serial myPort; // The serial port

void setup() { // List all the available serial ports println(Serial.list()); // I know that the first port in the serial list on my mac // is always my Keyspan adaptor, so I open Serial.list()[0]. // Open whatever port is the one you're using. myPort = new Serial(this, Serial.list()[0], 9600);}

In Serial Monitor, I am getting around 160 on a reflective surface (white) and 16 on a black surface. I also tried flashing StandardFirmata sketch and tried Serial Monitor again but I don't get any readings. I do get a reading from my own sketch though.