The purpose of this page is to demonstrate the operation of the
TSL239R light to frequency converter. The device outputs a 50% duty square wave whose frequency is proportional to light intensity. Not only can the TSL230R be used for detecting light intensity to adjust say lighting levels, it's sensitive enough to be a motion detector by measuring small changes in light level due to the motion of an object.
The program below is very basic in measuring the positive on time of the square wave and calculating the frequency, acting as a crude frequency counter. The same basic setup can be used with any number micro-controllers.
Step 1: How It Works
Note fig. 1.
The TSL230R provides three levels of sensitivity (in addition to an off state) to accommodate the measurement of nearly any light intensity. This is accomplished by dividing the photodiode array into sections which can be enabled or disabled to provide the needed sensitivity. The sensitivity is set by setting the appropriate levels on control pins S0 and S1. Output Frequency Scaling
The raw output frequency can vary from approximately 1 Hz to over 1 Mhz. Since the top frequency output is so high that some micro-controllers, such as the BASIC Stamp, are unable to measure the frequency, two pins (S2 and S3) on the TSL230R are provided as a frequency divider setting making it possible to measure the output frequency with slower micro-controllers.
Note fig. 2 connection to Arduino:
Pin out on TSL230R:
1 S0 Sensitivity select input
2 S1 Sensitivity select input
3 OE Output Enable
4 GND Ground 0 V
5 VCC/VDD +3 to +5 VDC supply voltage
6 Scaled-frequency output
7 S2 Scaling select input
8 S3 Scaling select input For
Arduino code and TRS260R spec sheet see: