Electronic – arduino – Latching switch ideas

arduinoavrmicrocontrollerswitches

I'm trying to build a latching switch connected to a door and would appreciate ideas.

The switch is connected to a microcontroller input pin, and I'd like it to operate as follows: When a person opens and closes the door, it latches on. It remains on until it is reset in software.

The basic idea is to time how long since the door was opened and closed again, and do something based on that. Once I have done this, I can reset the switch again. It does not matter if the door is opened or closed several times.

I'm not sure where to start, so any ideas welcome.

Best Answer

Most modern MCUs like the Atmel AVR (used in Arduino) have the ability to sleep in a very low power state (< 1 uA) and wake up from a variety of sources including low-power timer driven by 32 kHz crystal or pin change interrupts. Using a pin change interrupt or a low level triggered interrupt can wake up the AVR microcontroller from deep power down. Then the state can be saved in a program variable. See http://www.atmel.com/avr

An alternative hardware-only approach to a latching switch is the RS latch built from two 2 input NOR or NAND gates with output fed back to one of the 2 inputs. Whenever the output goes high, the feedback holds it in that state until the other input is pulled high to reset the latch.

Atmelfaebrian