Hi. Basically I have a circuit where I have a photocell and a led. If the photocell reads more than certain amount of light it turns on, otherwise it doesn´t. This works just fine, the problem is thought that the photocell only reads the amount of light one time, but I need it to read it constantly each second:
int sensorPin = 0;
int sensorValue = 0;
int LEDpin = 13;
void setup() {
Serial.begin(9600);
pinMode(LEDpin, OUTPUT);
}
void loop() {
sensorValue = analogRead(sensorPin);
Serial.println(sensorValue);
delay(2000);
if (sensorValue > 1000)
{
digitalWrite(LEDpin, HIGH);
}
else
{
digitalWrite(LEDpin, LOW);
}
}