Question regarding Servo including Serial monitor display I tried to make code following your instruction about mills, 
and it looks like this. Unfortunately, it is not working. Is there problem with my code?

Here is my code:


#include &lt;LiquidCrystal.h&gt;
#include&lt;Servo.h&gt;

Servo myservo;  // create servo object to control a servo

// These constants won't change. They're used to give names to the pins used:
const int analogInPin1 = A0;  // Analog input pin that the photosensor is attached to
const int analogInPin2 = A1;  // Analog input pin that the photosensor is attached to
const int analogInPin3 = A2;  // Analog input pin that the photosensor is attached to
const int analogInPin4 = A3;  // Analog input pin that the photosensor is attached to
int sensorValue1;   
int sensorValue2;   
int sensorValue3;   
int sensorValue4;   
unsigned long m;

//declare counter as an input
int Chactr =0;
int Disctr =0;

byte state; 

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  myservo.write(0);  // back to 0 degrees.
  delay(1000); // wait for a second.
  pinMode(13, OUTPUT); // initialize digital pin 13 as an output.
  Serial.begin(9600);  // initialize serial communications at 9600 bps:
  lcd.begin(16,2);

  delay(5000);
}

void loop() {

  // read the analog in value:
  sensorValue1 = analogRead(analogInPin1);
  sensorValue2 = analogRead(analogInPin2);
  sensorValue3 = analogRead(analogInPin3);
  sensorValue4 = analogRead(analogInPin4);

  delay(3000);

  // print the results to the Serial Monitor:
  Serial.print("sensor1 = ");
  Serial.print(sensorValue1);
  Serial.print("\n");

  Serial.print("sensor2 = ");
  Serial.print(sensorValue2);
  Serial.print("\n");

  Serial.print("sensor3 = ");
  Serial.print(sensorValue3);
  Serial.print("\n");

  Serial.print("sensor4 = ");
  Serial.print(sensorValue4);
  Serial.print("\n");

  Serial.print("Led State:  ");
  Serial.println(state);
  Serial.print("\n"); 


  if (sensorValue1 &gt;=569 &amp;&amp; sensorValue2 &gt;=520 &amp;&amp; sensorValue3 &gt;=419 &amp;&amp; sensorValue4 &gt;=250)
  {
    m=(millis()+60000);
  }

  if(sensorValue1 &lt;=568 &amp;&amp; sensorValue2 &lt;=519 &amp;&amp;sensorValue3 &lt;=418 &amp;&amp; sensorValue4 &lt;=249)
  {
    m=0;
  }

  if (sensorValue1 &gt;=569 &amp;&amp; sensorValue2 &gt;=520 &amp;&amp; sensorValue3 &gt;=419 &amp;&amp; sensorValue4 &gt;=250 &amp;&amp; m==millis())
  {
    state=1;
    delay(5000);
    digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
    delay(5000); // wait for a second

    myservo.attach (9);
    myservo.write(30);
    delay(3000);
    myservo.write(0);
    delay(3000);

    myservo.detach ();
    delay (1000);

    Disctr = Disctr + 1;

    delay(900);

    Serial.print("Battery Full: Discharge ON");
    Serial.print("\n");
  }
  else if (sensorValue1 ==0 &amp;&amp; sensorValue2 ==0 &amp;&amp; sensorValue3 ==0 &amp;&amp; sensorValue4 ==0 )
  {
    m=(millis()+60000);
  }

  if(sensorValue1 &gt;=1 &amp;&amp; sensorValue2 &gt;=1 &amp;&amp; sensorValue3 &gt;=1 &amp;&amp; sensorValue4 &gt;=1)
  {
    m=0;
  }

  if(sensorValue1 ==0 &amp;&amp; sensorValue2 ==0 &amp;&amp; sensorValue3 ==0 &amp;&amp; sensorValue4  ==0 &amp;&amp; m==millis())
  {
    state=0;
    delay(5000);
    digitalWrite(13, HIGH ); // turn the LED On by making the voltage high
    delay(5000); // wait for a second    

    Chactr = Chactr + 1;
    delay(900);

    Serial.print("Battery Empty: Charging ON");
    Serial.print("\n");
  }   
  {
    lcd.setCursor(0,0);
    lcd.print("Charge Cycle: ");

    lcd.setCursor(13,0);
    lcd.print(Chactr);

    lcd.setCursor(0,1);
    lcd.print("Discha Cycle: ");

    lcd.setCursor(13,1);
    lcd.print(Disctr);

    delay(1000);
  }
}
So what you want to do is be able to activate the servo when 4 green bars appear over the course of one minute correct?

I think you would need to create three if statements and one new variable. The first if statement will be, if it detects four green bar, then m=(millis() + 60000). Then you will need to nest another if statement in here to say if it detects ONLY three bar, then m = 0. 
Your third if the statement is if it detects the four green bars AND m == millis() then the servo will activate.

This is how I would do it, but I am not very experienced. I'm pretty sure others will have a cleaner and simpler code but this should work.