I am working out a control circuit for a light fixture to educate myself about the workings of smart bulbs.
To the best of my knowledge, smart bulbs usually require the light switch on the wall to be left ON, otherwise the bulb gets no power and cannot do its smart things. And they often have functionality for detecting when the light switch is turned OFF and then quickly back ON, so that they can be manually turned on when needed.
This requires that an Arduino can detect momentary loss of power when the light switch is turned OFF and then back ON, and respond appropriately.
My solution to detecting power loss is to split the output from a transformer into two lines, one is turned into 5V DC and another remains at 12V DC.
The 12V line can power the Arduino via the Vin pin or barrel jack. It has a capacitor so that the Arduino stays on during momentary power loss. I understand that the Arduino will stay on until the capacitor drops to something like 6.2V, which is the minimum for the Vin pin?
The 5V line is connected to a digital pin. When there is momentary power loss, the 5V line drops to 0V and then back to 5V when power is restored. My reasoning is that this power loss can be detected via the digital pin as HIGH-LOW-HIGH.
Will this approach work? Am I missing anything important, such as something that could damage the digital pin?
Am I overlooking a simpler way to do this? All I want is to power the arduino from a transformer, and be able to detect momentary power loss to the transformer caused by turning a light switch OFF and back ON.
Many thanks in advance for your guidance.