Added ability to read index pin.
Implemented main functions for PIC.