I'm building an AC dimmer with arduino, but I also want to have the ability to control the lamp from the wall switch (just on/off, with no dimming). What is the best way to achieve this? Do I also need to have a relay, so the two way from the circuit would be the relay's Normally Open (NO) and Normally Closed (NC) poles? Will the dimming circuit work with the relay, or will it cause any interference to it? Thanks!
There are two ways you can do this.
1 - Power the Arduino from the wall switch control.
This way when you turn the switch off, the Arduino turns off and so does the lamp. When you switch the power back on, Arduino boots and dimming will work as usual.
Pros: no power consumption when off, somewhat easier to wire.
Cons: have to wait to boot when you turn light on, Arduino may get unexpected power downs (if you are saving or transmitting data for example).
2 - Power the Arduino from another, permanent power socket, and read the Switch as an input.
This way the Arduino is always on and dimming, and whenever it detects a change of state in the wall switch it decides what to do (turn on/off, dimm, etc..)
Cons: a bit harder to wire (you either have to re-wire the switch for DC - thus removing original functionality - or optocouple your input to read if AC is connected)
Pros: Arduino is always on so no boot delays, you can add power up and down fade-in/outs, etc..