So i am terribly uneducated with arduino stuff because its not really much of a hobby, i just do amateur tinkering and stuff.
So what im trying to do is use a photocell and an LED so that when the light levels reach below a certain threshold it lights up the LED, the problem im having thought is that the LED is always on with a very very tiny light and putting my finger over the sensor or shining light into it does not effect the LED.
My code is
int lightPin = A0;
int lightReading;
int lightValue = 0;
int ledPin = 7;
Well, normally you would add some Serial.print statements to tell you what the value you were reading actually is. What voltage does this photocell of yours put out? How does that voltage scale with the incident light? Ar you sure your pgotocell isn't actually a light-dependent resistor? If so, you need to wire it up with another resistor to get a voltage splitter.
aarg:
The LED will not come on unless you configure the pin as an output. By the way, you are using a current limiting resistor, right?
im using an RGB LED and i found that they do not require a resistor although it is recommended, they output much more light but tend to overheat after 5 minutes
BogdanT:
im using an RGB LED and i found that they do not require a resistor although it is recommended, they output much more light but tend to overheat after 5 minutes
Wrong, wrong, totally wrong. The danger is not limited to the resistor. You could burn out an Arduino output too. Why not fix it while you are still not powering the LED due to your programming error?
BogdanT:
im using an RGB LED and i found that they do not require a resistor although it is recommended, they output much more light but tend to overheat after 5 minutes
If the LED produces that much heat I think it draw dangerously (for the output pin of the arduino) high amount of current. You really should use a current limiting resistor.