For a start, I wouldn't use pins zero and one for anything other than serial debugging.
Numbers are stored internally in binary - converting to and from Strings is completely pointless - have a look at the bitRead function.
I don't pretend to understand your loop () function, so I won't comment.