I'm trying to use a microcontroller to control a lightbulb. I would like to execute a command if the switch is flicked three times sequentially. What would be the best way to sense for this, since the microcontroller would be reset if the switch went off? (sorry, not much of an electronics person)
Use a capacitor to maintain the supply to the micro during the interruptions. Sense the supply line with port pin so that you can count the interruptions.
You could simply add a big capacitor to the UC. As personal experiencie a 3300uF takes like 3 or 4 seconds to discharge with a hole arduino uno on the rails. the time of the swithc off is important, yet I belive you can use an arduino with out the LED, for long lasting periods of time, and double the capacitance for give almost 10sec off switch. For read the mains, you could use an HCL 3700 IC, this device make easy and safe to read 220 / 110 or 24 VAC, and give you an clean digital input for the micro controller.
Hope it helps. -Alex.