Light to Frequency help

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(){

#  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

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


p.s. I have the chip wired up as instructed in this tutorial

hmm, you probably have something wrong with your circuit. the code looks short and fine. wiggle the wires around and see if anything changes

I double checked, everything is plugged in right.

I printed out an analogRead of the input pin, it is still shifting between 0 and 1024 with nothing in between, which is what I think is what a pulse would look like, if I shine a bright light on it, the numbers range from 300-500 with a lot of inbetween numbers, so I know that the sensor is sending data to the arduino, the question is how to use that data.

If I print a digitalRead I get nothing but 0’s still.

I would think that a 1000 would read as high, and 0 as low.
I’ve read that the light should influence the frequency, with is the distance between low and high, but I can’t even get a reading of low and high.

am I making false assumptions on how this thing works?

Does that sound like a problem with the chip still? or maybe the Arduino? the code?

Im using an Arduino Mega if that makes any difference.

thanks again for the assistance!


Problem solved, because I was using Arduino MEGA, the
#define TSL_S0 5
#define TSL_S1 6
#define TSL_S2 7
#define TSL_S3 8
where actually Analog Inputs

I hooked it up to a Duemilanove and it appears to be working now.