if statement with time interval

Hi,

I am a newbie in arduino.
I need help guys.
I have made a solar tracker using an arduino UNO. I have used IF statement to compare the value given by two light dependent resistor. My program runs okay, however there is a problem during cloudy days. The values given by the LDR's are inconsistent making the tracker move erratically.

How can I add a line in the program that the operation of the IF statement will only be executed if the value is constant for more than 10 seconds.

Thanks

now = millis();
value = read_value();
if (value != last_value)
{
   last_value = value;
   timer_start = now;
}
else if (now - timer_start > 10000)
{
  // Steady for >10 seconds - Do something here
}

Thank you for your reply sir.
However still a bit confused since I am still a newbie.

here is the code I made for my tracker

int myPin1=A1;
int myPin2=A2; //light resistor eastside:
int readVal1;
int readVal2;
float V1;
float V2;
int delT=500;
int redLed=6;
int yelLed=8;
int grLed=7;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(myPin1,INPUT);
pinMode(myPin2,INPUT);
pinMode(redLed,OUTPUT);
pinMode(yelLed,OUTPUT);
pinMode(grLed,OUTPUT);
}

void loop() {
// put your main code here, to run repeatedly:
readVal1=analogRead(myPin1);
V1=(5./1023.)*readVal1;
readVal2=analogRead(myPin2);
V2=(5./1023.)*readVal2;
Serial.print(V1);
Serial.print(" and ");
Serial.println(V2);

if(V2>V1+0.5){
// here is where i need to keep that if statement for 10 seconds before executing the operation below
digitalWrite(grLed,LOW);
digitalWrite(yelLed,LOW);
delay(100);
digitalWrite(redLed,HIGH);
}

if(V2+0.05==V1+0.05){ //no movement if tracker is balanced:
digitalWrite(redLed,LOW);
digitalWrite(yelLed,HIGH);
digitalWrite(grLed,LOW);

}
if(V1>V2+0.5){
digitalWrite(redLed,LOW);
digitalWrite(yelLed,LOW);
delay(100);
digitalWrite(grLed,HIGH);
}
if(V1<1.5,V1>0.021 && V2<1.5,V2>0.021){//avoids tracker moving west during cloudy days:
digitalWrite(redLed,LOW);
digitalWrite(yelLed,HIGH);
digitalWrite(grLed,LOW);

}
if(V1<0.02 && V2 <0.02)
{ //turns baack tracker to east during night time:
digitalWrite(yelLed,LOW);
digitalWrite(grLed,LOW);
digitalWrite(redLed,HIGH);

}

delay(delT);
}

Does this statement work the way you expected it to?

if(V1<1.5,V1>0.021 && V2<1.5,V2>0.021){

Also, please read the first three posts at the top of this Forum. They will tell you how to properly post code here using code tags.

i think its not working since tracker moves erratically on cloudy days
i will delete this in my code

I have a question sir.

if(V2>V1+0.5){// I need this condition to be at least 10 seconds before it will execute the operation, if this condition is not more than 10 seconds then it should not execute the operation below

digitalWrite(grLed,LOW);
digitalWrite(yelLed,LOW);
delay(100);
digitalWrite(redLed,HIGH);
}

thanks

It will not be productive to try and answer any more questions about your code, without seeing the entire updated sketch. Please post it here, but before you do, definitely read the forum sticky posts at the top of the forum, about how to post code (especially how to put it inside code tags in your message).