void loop()
{
Serial.println(analogRead(lightPin)); //Write the value of the photoresistor to the serial monitor.
analogWrite(ledPin, analogRead(lightPin)/4); //send the value to the ledPin. Depending on value of resistor
//you have to divide the value. for example,
//with a 10k resistor divide the value by 2, for 100k resistor divide by 4.
delay(400); //short delay for faster response to light.
}
Stay lit for exactly 30 sec and always turn off? How long before it can turn on again? Stay lit for at least 30 sec each time? You need to be more explicit in describing the behavior you are after.
Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Hi,
Usually when a problem has been solved on the forum, the successful end result is posted so any one using the forum with a similar problem can find a solution.
A copy of your code and if possible a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png will help accomplish this.
This way the forum is not just a learning curve for you but will help others on similar learning curve.
Your specification is ambigious as pointed out above. Let me be even more specific with the questions you will have to answer before you can even start to implement this project.
Activation lasts some time (can be seconds, can be very short, but it's not zero time). Count from start or end of activation event?
Switch on right away when activation is detected, or wait for activation event to be finished?
Activation can happen again while the LED is lit already. Start counting anew?
When the 30 seconds are over, will a new activation light it right away, or requires it a delay? What to do with activation events during the delay?