I need help with connecting a photo diode to my arduino-mega (atmeg1280).I'm using a photodiode form thorlabs http://www.thorlabs.com/thorProduct.cfm?partNumber=DET36A.The problem I'm encountering is that when there is no light being pass through the photo diode I would like it to output a value of 0 to the arduino. However when I check the serial monitor it shows me that its receiving some sort of light.I have connected the photo diode to analog pin 0 and ground.

myservo.write(pos); // sets the servo position according to the scaled value delay(150); // waits for the servo to get there Serial.print(" Servo position = "); Serial.print(pos); Serial.print(" Diode = "); Serial.println(intensity,DEC); } while (desiredValue!=intensity); //run while the intensity is not the same

However when I check the serial monitor it shows me that its receiving some sort of light

The device is sensitive well into the infra-red spectrum - are you certain that the device isn't receiving any light?How is the device wired?You've shown a sketch that has lots of extraneous stuff like a servo - where is the basic test sketch and what does the output look like?

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.Do not send technical questions via personal messaging - they will be ignored.

The purpose of this project is to reduce the intensity of a laser with a polarized lens. The lens is connected to a servo motor which allows it to rotate. The photo diode records the intensity of the laser after it passes the lens. It will then compare the actual intensity to the desired intensity and rotates the lens until the desired intensity is reached. The photo diode has 2 wires one which is connected to the analog pin and the other is connected to ground.

Is there a way to change the sensitivity so that it only detects visible light? The way device is wired is the servo is connected to pin 10, power and ground and the photodiode is connected to analog pin 0 and ground.

According to the datsheet (http://www.thorlabs.com/Thorcat/13000/13051-S01.pdf)the sensor will output 0 to 10V, which is too high for the Arduino input pin to measure directly (5V max), so you will need to build a voltage divider or similiar method to lower the output down to something less than 5V. Check out the voltage divider tutorial over at Sparkfun for more info : http://www.sparkfun.com/tutorials/207.

FYI - I think you should also clear up your code and print out the actual values you are reading from the input pin and not the mapped ones:

Yes, you are right, 50 ohm. Thanks.Value is pretty low. It'd make sense, if OP doesn't need fast response time (which isn't required to move servo),to increase R up to 50 k ohm , may be more. For high value resistors, susceptibility to EMI and higher noise level have to be considered.