How use millis()?

Hi guys in my project of domotic, i need of this:

i have a sensor of light and pir sensor, when the brightness value exceeds a certain limit (means light is ON), start a countdown (10000 millis), if the sensor pir is LOW for 10 second set a pin LOW, if sensor pir is HIGH, reset countdown. how would you do?

void setup() {
   pinMode(PINLED, OUTPUT); //LED
   pinMode(PINPIR, INPUT); // PIR

timer.setInterval(1000L, sendSensor);

void sendSensor() {
   int pir = digitalRead(PIRPIN); // pir cabina
   int pinlight = analogRead(PINLIGHT); // sensor light
   if (pinlight > 100) {
   // start countdown 10000 millis
      if (pir == HIGH) {
      //reset countdown    
      else if (countdown==0) {

void offled() {
   digitalWrite(PINLED, LOW)

void loop()

I hope is clear

Use timers instead of millis.


If I remember correctly there is an example of a countdown timer which works very well on the forum

can you send me a link?

Just search for CountDown and you will find it. It was posted by Jamin