I am currently trying to set up a simple spectrophotometer in which I have 10 LED's of different peak output wavelengths ranging from 400 to 700 nM, and I have a photodiode (this one to be specifichttp://www.mouser.com/Search/ProductDetail.aspx?R=TSL257-LFvirtualkey57530000virtualkey856-TSL257-LF.
The setup is as follows: The LED's are mounted on a circular PCB that is attached to a stepper motor. A sample test tube is placed between an LED and the photodiode, and the motor rotates the LED disk and shines different LED's through the sample while the diode makes the reading.
The stepper motor is driven using a simple L293/298 pair and is pulsed by the Arduino using a digitalWrite HIGH/LOW loop. The diode emits a signal ranging from 0 to 5 V and is being read using analogRead, and the LED's are being driven and dimmed using analogWrite.
The issue I am having is that when an LED is driven using PWM, the sensor is fast enough to be able to detect each pulse of the LED. When hooking up the photodiode to a scope and having it read the intensity of the LED, it fluctuates between ang. This is because the response time of the diode is less than 1 microsecond as given by the data sheet. So when the Arduino does an analogRead on the sensor pin to get its voltage, the voltage could be pulsing anywhere between 0 and 0 to 5 V at the rate of the LED PWM while the reading is occurring (because it takes about 100 microseconds to perform an analogRead), so I get all sorts of analogRead values that are useless. When illuminating the photodiode using digitalWrite and dimming the LED using a filter of sorts, the analogRead values are 100% accurate because the light isn't pulsating.
So what do I do to get an accurate value of light intensity when dimming the LED using PWM???
I wanted to know how I could go about obtaining an accurate reading from the photodiode