haristadena:
1.5V square wave is fed to pin A1. At A2, I want a 180 degree phase shifted wave.
Is this a school assignment or so? In the real world I'd use a 74HC04 inverter for a job like this.
You're doing analogRead() which takes about 100 us to complete - so your second wave is always lagging by that much. For your wave you'd have a 10% time lag just because of that, not counting the time it takes for your code to process the number and write it out to another pin (which should be far less).
You can improve big time of course by simply copying the value of one pin to another, but you're never going to get in to the nanoseconds it takes a 74HC04 to propagate your signal.