Using a voltage divider (2 resistors) with **AC** will also give you a **negative voltage** on the analog input. According to the ATmega datasheet the **maximum allowed negative input voltage** for any pin is -0.5volts.

So your voltage divider should not give you more than **0.2 volts** (just to be on the save side). As you just want to detect the zero-crossing you need to write a routine that gives you a signal when the zero crossing from positive to negative occurs and another signal when the negative to positive crossing occurs.

In other words, you want 2 signals - one when the input will give you an analog reading of 0 and one when it gets back to a value higher than zero. Your input signal will be on the negative side for half your puls lenght if your signal is symmetrical.

As you just want to detect the zero crossing, **accuracy is not a problem**, so a 0.2 volts input should be OK.

It is very important that your routine is fast enough that it will not loose the zero crossings.

As far as I know an analog input cannot generate interrupts when in analog mode, so in your case interrupts would not be a viable solution to compensate for long routines.

Another solution would be to use a rectifier diode in front of the voltage divider, that protects you from negative voltages.
In this case you could use a higher input voltage for your analog input (up to 5 volts). This is only required when your input signal has a sinewave form, because in that case it might take some time between a 0 and a 1 or higher reading. In that case the frequency is also a factor.
And in that case your analog output might never go down to zero (voltage divider in parallel with internal electronics). So your desired switching point migth be 3, 6 or even 10 (analog output value).

If you have a rectangle waveform, you do not have to care about this and the above 0.2 voltage solution will work perfectly.

Like always, there are several solutions.