unsigned int GetX() { //reading X PORTC.F0 = 1; // DRIVEA = 1 (LEFT drive on, RIGHT drive on, TOP drive off ) PORTC.F1 = 0; // DRIVEB = 0 (BOTTOM drive off ) Delay_ms(5); return ADC_read(0); // reading X value from RA0 (BOTTOM) } unsigned int GetY() { //reading Y PORTC.F0 = 0; // DRIVEA = 0 (LEFT drive off , RIGHT drive off , TOP drive on) PORTC.F1 = 1; // DRIVEB = 1 (BOTTOM drive on) Delay_ms(5); return ADC_read(1); // reading Y value from RA1 (from LEFT) } void main() { PORTA = 0x00; TRISA = 0x03; // RA0 i RA1 are analog inputs ANSEL = 0x03; ANSELH = 0; // Configure other AN pins as digital I/O PORTC = 0 ; TRISC = 0 ; // PORTC is output ... while (1) { // read X-Y and display it x_coord = GetX(); y_coord = GetY(); ... Delay_ms(100); } }