Hey everyone, I recently purchased a TSL230 from sparkfun As I understand it, this little guy outputs a square wave with a frequency that is influenced by the intensity of light. Looking around at previous posts I found this code
long pulseTime;
#define pulsePin 3 // change this to input pin
#define TSL_S0 5
#define TSL_S1 6
#define TSL_S2 7
#define TSL_S3 8
void setup(){
Serial.begin(9600);
# pinMode(TSL_S0, OUTPUT);
# pinMode(TSL_S1, OUTPUT);
# pinMode(TSL_S2, OUTPUT);
# pinMode(TSL_S3, OUTPUT);
#
# digitalWrite(TSL_S0, HIGH);
# digitalWrite(TSL_S1, LOW);
# digitalWrite(TSL_S2, HIGH);
# digitalWrite(TSL_S3, HIGH);
}
void loop(){
// first two lines prevent reading an incomplete pulse
pulseTime=0; // clean out variable
while(digitalRead(pulsePin) == 1){}; // find a high pulse
while(digitalRead(pulsePin) == 0){}; // find a low pulse
while(digitalRead(pulsePin) == 1){ // we know we are at the beginning of a clean pulse now
pulseTime++;
}
Serial.println(pulseTime); // debug variable
}
I'm not getting anything values sent back when I run this, it acts as if the arduino does not see any high/low pulses. It should send me some sign that the arduino is reading each pulse
if I try printing out the digitalRead value of the input pin, I get nothing but 0 if I try printing out the analogRead of the input pin, I see 0 and 1000, so I know there is some input coming from sensor. Isn't the 0 - 1000 a pulse, on/off?
I'm unfamiliar with how this is supposed to work, so forgive me ignorance.
The goal is to have the sensor see a bright object on my LCD TV screen and trigger an action through the arduino, I chose this chip because I'm hoping it will get me a very clean absolute input so I don't have to burden the Arduino with averaging out and cleaning up an analog signal.
thanks for the help
-joe
p.s. I have the chip wired up as instructed in this tutorial http://roamingdrone.wordpress.com/2008/11/13/arduino-and-the-taos-tsl230r-light-sensor-getting-started/