I'm working on a simple setup using an Arduino Nano to automate the switching of my car headlights when it gets dark. I am happy with how to program the Arduino & LDR use and coding, it will be powered using a DC-DC buck converter to convert the 12.9V(ish) to around 7V. I intend to power the Arduino from the switched live circuit in the car, so that it will not draw power when the car is not in use, and as it will control a normally open relay, there is no risk of the Arduino accidentally turning on the lights when it's parked up. (relay will be on the low current switch side of the OEM factory wiring, before the main headlight relays, there will also be a switch to isolate the Arduino and operate the lights as normal)
However I would like to have it so the lights stay on for 5 minutes or so after the car is switched off, would this be possible using a capacitor or similar that charges when the Arduino is powered, and continues to power it after the power is cut? I assume I would need some circuitry to ensure the cap provides stable current/voltage during discharge, although the Arduino is helpful in being able to run on anything from 5-12V. This would give me automatic lights when the car is on(or the key is turned in the ignition at least), but ensure there is no way for the lights to come on accidentally.
Any help is much appreciated. I asked this question on an Arduino forum but most answers just advised to power the Arduino constantly and do the delay with code, which is something I really want avoid as the car is not used everyday, and I don't want to have to jump it because the Nano has drained the battery.