Hello. I have a design like this:
(https://dl.dropboxusercontent.com/u/38903109/EEVBlog/Images/Misc/piwnica1.jpg)
I dont know how to detect AC signal from switch. This switch isn't turning anything on. By signal I mean 0 (off) or 1 (on).
I thought to use bridge rectifier and optoisolator but I'm afraid that connecting only this to 240V will cause loads of sparks and eternal darkness.
Is there any simple way to get signal from 240V? It would be great if I can isolate switch input because uC will be powered by battery in future.
Why not just use a 240VAC relay for that, with the micro reading the contacts to determine if the relay is activated or not?Well... It sounds like a solution :D
And about triacs, yeay, they are fun. But the require a bit more knowledge then a relais. (Heat, snubbing etc). If jou don't want to dim the light/output I would use a relais as well. You can buy cheap modules which already have the relais, diode, transistor and resisors in place and just need 5V, GND and an input.
I took a fresh look at the optoisolator category. I've discovered the LTV-824. It's a tenth the price and can serve the same purpose adequately. The only real gotcha is that it's not an intentionally slow transistor like in the MID-400, which means your controller would have to poll for a millisecond or so to insure it doesn't mistake a zero crossing for absence of voltage.
I took a fresh look at the optoisolator category. I've discovered the LTV-824. It's a tenth the price and can serve the same purpose adequately. The only real gotcha is that it's not an intentionally slow transistor like in the MID-400, which means your controller would have to poll for a millisecond or so to insure it doesn't mistake a zero crossing for absence of voltage.
Use a pullup resistor and capacitor network with a time big time constant (1 second or so), use the output of the optocoupler to discharge the capacitor.
The capacitor voltage will stay "low" as long as the ac signal is present.
Use a comparotor to detect if the capacitor voltage is "high" or "low".