I'm trying to create a motorcycle black box/dashcam. I would like to use an arduino to start a small video camera when a motorcycle is turned on, and recording is stopped after it's turned off. Starting the system when power is turned on is easy, stopping it when power is turned off is the tricky part.
Here's what I was thinking: - small camera (808 keychain) with it's own battery. wires soldered to the power and start/pause button. - usb power to camera to keep onboard battery charged. Usb active only when vehicle is on. - arduino that is hooked up to 2 opto-couplers to simulate button press on power and start/pause buttons. - power to arduino from ???
I was thinking of using a battery on the arduino, but it will die after a short period of time. Also, connecting directly to bikes battery will drain it.
What I'm looking for is a way for the arduino to determine when system power changes from on-off and execute code when that happens. After this code is executed, the arduino should power down until power is applied to the system again.
Here is a simple chart showing when power for the various devices would be on bike power on|---------------|off Arduino power on|---------------------|off Camera Power on |------------|off
What options do I have here that would require zero power to the arduino after the camera 'stop' code is executed? Or is there a better way of doing this (that doesn't require purchasing a dashcam)?
thanks in advance.