Suggestions on code for reading square wave input

Check the pulsein() function

http://arduino.cc/en/Reference/PulseIn

It might do the trick depending on voltage level and frequency.