VictorA:
I'm trying to make a circuit that makes a quarter-wave cut to the input voltage
So you have AC input? What frequency/amplitude? Image suggests 5 Hz which is quite slow.
How is everything wired?
In to your program you switch off your relay for two seconds whenever the voltage on A0 drops below 2.56V (you do make sure not to get negative voltages there? Why below, not above that value?). If you want to switch it on at the peak you'd instead need to do some peak detection unless you're very sure about the peak level of your signal.
OP's image:
