I have a small project I'm working on (motion activated night-light, with a photoresister so it only turns the LED on when it's dark)
I have it working 100% on a breadboard with an Arduino Uno.. If I cover my fingers over the photoresister and it detects motion the LEDs turn on.
I programmed an ATiny85 so that I can put this into a smaller package and free up my Arduino for some other purpose, for the final version of this when I'll put this into some kind of small housing/box.
I'm running into an odd issue when I set it up with the ATtiny85 vs Arduino. I experimented with the "threshold" settings of the photoresister when it was connected to the Arduino to find a threshold number that worked well, this number was around 500 for example. When there was some light in the room it would not light up. Perfect.
When I first hooked it up with the ATtiny85, I couldn't get the LED to light up no matter how dark I made it, and after tearing my hair out I reprogrammed the chip with a really small threshold and low-and-behold the LED's light up when motion is detected.
OK so I was getting somewhere... but...
I kept experimenting with thresholds and and I can only get it to work in an all-or-nothing scenario. The magic number of the threshold that makes the LED's light around 250 and under, but the problem is that it even lights up if I put full sunlight on it
If I use a larger threshold the LED's never come on at all no matter how dark it is, and a smaller threshold the LEDs come on no matter how bright it is.
In other words, I have experimenting with various settings and I can't get it to light up ONLY when it's dark. If I raise the threshold it just won't work at all (with the ATtiny)
This is the resistor I am using:
Photoresistor - VT935G-B 350-00009
http://www.parallax.com/tabid/768/ProductID/175/Default.aspx
This is my project by the way in case you want to see how it's set up:
http://arduino.cc/forum/index.php/topic,86152.0.html
The only difference between when the breadboard is hooked up to the Arduino and when it's hooked up with the ATtiny is power. The Arduino provides 5v, and with the ATtiny I'm powering my breadboard with 3 x AAA batters (so 4.5v)
I really don't know what I'm doing wrong.
These are my pin settings:
int pirPin = 1; //the digital pin connected to the PIR sensor's output PIR Sensor (Rev B) 555-28027
int ledPin = 0;
int lightPin = 2; //Photoresistor - VT935G-B 350-00009
int threshold = 275;
and then I connect power and ground to the ATtiny.
Any ideas?
Thanks