Friends, I'm new here in this platform. I was doing simple project. I've a door closing system(part of another project). To check it, I'm making a test kit. I need the following condition. If I give a closing command, the motor should run until it get the feed back as door is closed; and along with this I need to run a timer, which run Up to 10 sec. So the motor should off at any of these condition satisfy(timer or feedback sensor).
As I read another function can't be inside the Void loop. Please help me.
You can use millis() to track elapsed time.
Lots of millis() postings on this site, do a search.
there is an internal function called millis() which returns milliseconds since booting your arduino
so you make a snapshot of the current time
unsigned long starttime = millis();
by repeateds calls of millis() you can calculate the time that has passed by since you stored the snapshot
and then do something
see https://www.arduino.cc/en/tutorial/BlinkWithoutDelay
best regards
Stefan