Make Passcode Lockbox Re-lock When Box Lid Is Closed?

Hello. I’m a total newbie but have an idea for a geocache container…passcode entry lock box. However, for it to be effective ‘in the field’, I need the box to re-lock automatically after a person finds and opens it (can’t rely on people to ‘press a button to relock’). Closest I could come to finding what I was looking for was in this link where he mentions the lock resets to the locked state a few seconds after it’s opened.

Is this possible if using a passcode? If so, any suggested link that may help me learn more?
If not, any suggestions on a different approach to this geocache passcode container project?

Thank you.

If your Arduino passcode program saves the value of millis() when the lock is opened it can certainly reset the lock after a period of time with code something like this

if (millis() - timeLockOpened >= allowedOpenTime) {
   // code to reset lock


You could use a switch to detect when the lid is opened and closed.