I am using a TAOS TSL235R light-to-frequency IC to measure light levels inside of a tube. To read this accurately, I am using the FreqCount library I found here: FreqCount Library, for Measuring Frequencies in the 1 kHz to 5 MHz Range
I am running this on an Arduino Uno with the square wave output from the TSL235R connected to digital pin 5 on the Uno as Timer.h requires.
I also have an RGB LED connected to PWM pins 3, 6, and 9 on the Uno. I am currently only using the red LED which is connected to digital pin 3. When I run the code, the red LED does not illuminate. I have tested this connection with the Blink example, and it works fine. I have also tested with both the blue and green LEDs as well. They work.
So, it seems like there is something going on that is specific to the FreqCount library, Timer.h, or something else in that library that doesn't play well with digital pin 3 when I run it.
Any ideas?
Here is my code:
#include <FreqCount.h>
// Connect square wave freq output from TSL235R to DIO5 on Uno
// Connect square wave freq output from TSL235R to DIO47 on Mega
int LED_red = 3;
int LED_green = 6;
int LED_blue = 9;
int duty_cycle = 50;
int seconds = 0;
int fscale = 1; //divide by: 1, 2, 10, 100
void setup()
{
pinMode(LED_red, OUTPUT);
pinMode(LED_green, OUTPUT);
pinMode(LED_blue, OUTPUT);
// Turn the red LED on to illuminate the sensor field of view
analogWrite(LED_red, duty_cycle);
Serial.begin(9600);
Serial.println("seconds, freq");
// Start the FreqCount function
FreqCount.begin(1000);
}
void loop()
{
unsigned long f = 0;
if (FreqCount.available())
{
// Read the counts per second multiply by fscale to get the
// actual frequency.
f = fscale*(FreqCount.read());
Serial.print(seconds);
seconds++;
Serial.print(", ");
Serial.println(f);
//Serial.print(" Hz\n");
delay(20);
}
}