So I have a Sharp IR sensor connected to my Arduino, feeding to my pc the values of its analog input, via the Serial connection.
To do this, I'm using the Serial.write() command. I want to be able to read these values into processing, but when I use the Serial.read() command in Processing, the values it picks up are nothing like what the Arduino Serial monitor is giving me, and are unaffected by the IR sensor.
What am I doing wrong, and how can I get processing to read these values from the IR sensor?
You are trying to send 10 bits (the adc on your arduino is 10 bit (0-1023)). When sending to the serial monitor, the fact that you are not sending 8-bit bytes is sorta taken care of for you. When you get to processing, those extra 2 bits (actually a second byte) is screwing everything up. The easiest solution is to divide your ADC reading by 4 to make it a byte and then send it. If you want more accuracy, you will need to receive 2 bytes on the processing side (high and low) and then put them back together into your big number.