can i use a power source as an input/event trigger?

I want my project to be able to detect when a car has been turned off, which would then trigger the project actions. A friend suggested using the 12V power adapter plugs (cigarette lighter plug), since they should power off when the key is removed. I was thinking of using a 5V adapter (such as a cellphone charger with USB connection) to get power for the device, but is there some way of wiring it so that it can detect when the power is off and then use that to trigger other events?

At this point, I have a LilyPad Arduino, but am open to other boards as needed.

Thanks

Well one way is to have a reverse optocoupler/relay. Normally you use an optocoupler to have an Arduino turn on/off a secondary device, so the Arduino is connected to the input pins. However, you can do it with the device powering the optocoupler, and connecting a data pin to a 3.3/5v pin.

Not all cars have "cigarette lighter" any more, in many cars now they are just power outlets. My 2004 Jetta Wagon, I have had a Duemilanove powered from USB power adapter plug for a couple days now, still flashing merrily away. Power is live all the time, I watch it for upsets every time I stop & start the car.

Some of the atmel products (Not sure if the atmega32u does it) have a built in brown-out detector that will detect if power goes low and executes things frantically before losing all of its power. This may be too complicated and tricky.

Additionally, if its far and above the voltage requirement of your board (IE 12V for your 5V Board), you can just measure it before using a voltage divider before the regulator and feed it into an ADC and once it crosses a certain threshold, have it execute its stuff.

Finally if it has a separate power source, you can just measure the voltage. But like Crossroads said, some cars just always supply power. His does, mine doesn't.

CrossRoads:
Not all cars have "cigarette lighter" any more, in many cars now they are just power outlets. My 2004 Jetta Wagon, I have had a Duemilanove powered from USB power adapter plug for a couple days now, still flashing merrily away. Power is live all the time, I watch it for upsets every time I stop & start the car.

That's what I was afraid of. I do know that that is the case for some cars, though I know my 2003 Mazda just has the old school cigarette adapter that powers off with the key. I'll have to check our 2012 Toyota and see what it does.

mirith:
Some of the atmel products (Not sure if the atmega32u does it) have a built in brown-out detector that will detect if power goes low and executes things frantically before losing all of its power. This may be too complicated and tricky.

Additionally, if its far and above the voltage requirement of your board (IE 12V for your 5V Board), you can just measure it before using a voltage divider before the regulator and feed it into an ADC and once it crosses a certain threshold, have it execute its stuff.

Finally if it has a separate power source, you can just measure the voltage. But like Crossroads said, some cars just always supply power. His does, mine doesn't.

So, I do plan on having a battery attached so that it is not dependent on the car power to power the device. In my brain, that should avoid a brown-out freak out. I really like your idea of an ADC to check the voltage level and convert it to a digital signal the board can use, but I'll confess to being quite new to this and unsure how to go about attaching one (even though I understand the theory behind how it works). I searched SFE and found several different ADC chips, but they all seem to exist apart from a board. How would I build that into a LilyPad environment? Is there another board I need to add to accommodate the chip?

Thanks for the tips and helpful direction. :slight_smile: