I read all of your examples and I got a few questions.
I want to make codes which control LED. I intended to turn on/off the LED depending on the distance.(I use ultrasonic sensor to check distance)
For example if d is between 10cm and 20cm, LED will be on. (d=distance) And if d is between 10cm and 20cm for 5 seconds, LED will be off though it is in ‘ON-STATE’ distance.
My question is how I can do it by using ‘Millis’. plz help, especially ‘And if ‘ line .