0
\$\begingroup\$

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)

\$\endgroup\$
  • 1
    \$\begingroup\$ Do you want the microcontroller to control the light or the switch to control the microcontroller? Please clarify a little bit as it is not clear. \$\endgroup\$ – Eugene Sh. Jan 6 '16 at 21:55
  • \$\begingroup\$ Why are you flicking a lightbulb? \$\endgroup\$ – mcmiln Jan 6 '16 at 23:10
  • 1
    \$\begingroup\$ Search for 'infra-red lightswitch'. Buy one of those and use your micro to short the contacts of the remote pushbutton. You get the benefit of electrical safety by buying the readymade mains unit and hacking the battery-powered remote. \$\endgroup\$ – Transistor Jan 7 '16 at 1:24
1
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.