Digital 12 socket light dimmer. For christmas!

After reversing the action of the software and turning on after a delay, things worked just as bad. I hooked up to a real oscope at school today and found what seems to be the problem. Now the question is how to fix it. My zero cross trigger is 90deg out of phase. It triggers on the peaks and valleys. I suppose a quick fix would be to delay roughly 4ms extra but I am very puzzled on why it is not performing how I expect it to. Below I have included a basic schematic of my ZC detector and of the observed waveform. The black led is part of the opto (blue)--its AC input. Input resistor is 1k and the cap is somewhere in the .1 to .3uF range (don't remember-its SMD and doesn't say) My only thought was that the led wasn't turning on until mains was nearing 170V but this would show the output peaking downward not upward (to 5V). Any ideas?



EDIT BAhhhh I got the same exact results in a simulation as well. What the heck am I missing?