Hi, I am wondering if you could please help me work with a photocell code that I have. I would like for the photocell to turn an led on and am not sure what I have wrong in the code. I am quite new to this area of expertise and sure could use some help!
Here is the code that I have been trying to work with:
int InitialReading;
int Reading;
void setup()
{
Serial.begin(9600);
pinMode (11, OUTPUT);
InitialReading = analogRead(0);
Serial.print("Initial Reading= ");
Serial.println(InitialReading);
}
void loop()
{
Reading = analogRead(0);
Serial.println(Reading);
if(Reading>(60+InitialReading))
digitalWrite(11,HIGH);
if(Reading<= (60+InitialReading))
digitalWrite(11,LOW);
delay(1000); // waits 1 sec
}
Thank you for your time!