Using Millis with optical encoder

For example

if (temp == 100) 
if (temp == 200)
if (temp == 300)
if (temp == 400)
  {
    if (lastTempReading != temp)
    {
      ledState = 1;
      startTime = millis();
    }
  }