Hello everyone,
New to the forms.. I actually bought this arduino duemilanove to just act as a ligh or photoswitch. I also bought a mini photocell. I really just need help writting the program. Can anyone help me?
Needs:
when light is present no output
when it is dark full output.
needs to be checking at least once every minute.
This is what I got so far.
const int SensorPin=0; // input for photocell
const int LedPin=13; ///pin for led
const int Threshold=1022; //value of sensor
const int stop=0; //make it never ending
void setup() {
//delcare the ledpin as output
//initialize serial communication
pinMode(LedPin, OUTPUT);
Serial.begin(9600);
}
//void Why(){
//while(stop==0){loop();}
//}
void loop()
{
int SensorValue = analogRead(SensorPin);
if (SensorValue>Threshold){analogWrite(LedPin , SensorValue);}
else { analogWrite(LedPin,0); }
// print the analog value:
// Serial.println(SensorValue, DEC);
}
I am slightly confused do i just slect an arbitrary resistor. Also I am not an electronics expert by no means as a note. Also shouldn't the arduino act as a voltage divider. Cant the analog in switch just tell if there is zero volatge or +5 voltage. I just need a little more elaboration please, Thanks in advance for your help by the way.