traffic light project!

When the state change occurs, set a var like redMS to millis() + 180000 then have the loop look for for when millis > redMS to turn off the lamp (digitalWrite(ledR),LOW);.

Essentially you tell it a time to turn off from current time measured in milliseconds of up-time. I assume its for car parking. Have fun!