> I assume power ( HOT ) thru 4,7Meg resister should be connected to > one of pic pin then how do I synchronize it. I still do not clearly picture > it. Thanks for your help. My comments re driving levels being too low for the optocoupler used still apply but I didn't read your comments on driving closely enough - as noted by others, random PWM to an AC bulb will lead to unexp3cted results. I stsill suspect a major problem is the amount of drive. To detect zero crossing you CAN use a high value resistor bweteen mains and a PIC pin but this is EXTREMELY unwise for safety reasons - especially where your family is potentially (pun only slightly intended) being connected to the other end. Much safer is to use a second opto coupler to detect mains zero crossing Phase ----RRRRR---|>|-----Neutral | | --|<|-- Opto diode. This requires a high voltage capable R of suitable rating. Using a mains rated capacitor in series with the opto (and a resistor as well) will give less power dissipation. There are other ways to get mains zero crossing info such as small step down transformer, current transformer using a toroid etc. Using an opto with zero crossing function built in will make the task easier again. If you DO use a high value R directly from mains you must make sure that all low voltage parts are treated as if at mains potential and be SURE that the resistor will withstand mains voltage - ideally use two in series with each mains rated. ST electronics have an app note for the ST6 used as a mains lamp dimmer and no doubt many other people do too. regards Russell McMahon -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu