Voltage regulator frequency range
Neither. You should use a potential divider: 







simulate this circuit &ndash; Schematic created using CircuitLab

edit: Just to add, this will give a 0-4V wave at 24Vin, and a 0-2V wave at 12Vin. This is still fine, because the Atmega32 (supplied at 5V) will see anything above 2V as a "1".