I don't understand why you "and" PortA with decimal 48. Please explain
I originally had encoder on pins 4,5 . and missed fixing that line when I moved re pins to 5,6
it only sets re initial state so after first move its not important , the first move could be in error though
I should "and" PortA with decimal 96. for those pins