My senior design team are building a device that uses UV light for sterilization. We are new to arduino and programming. We are wondering how do we program the arduino to delay an LED light from turning on for 10 seconds.
Our project: We are buliding an automatic sterilization device that will go above door knobs. It will sense motion from the human interacting with the door knob, wait 10 seconds, and then light the LED light onto the door knob. We are using LEDs instead of real UVs for prototyping.
What code would be best to use to make this possible? We are using an Arduino Uno and a HC-SR501 PIR motion detector. Thanks!
You need to use the millis() function like the BlinkWithoutDelay example. When you PIR fires, record the current millis() time. When the time has advanced 10,000 milliseconds from that time, do your cleansing. You use the same technique (millis() elapsed time) to time your cleansing.
You should also become aware of Finite State Machine style programming as this will make your task easier. This article Finite State Machine Programming Basics – Part 1 – Arduino++ will give you start but there is lots on the web about this.