Megahertz,

That code I posted above I wrote it some time ago. It was part of a program that sent the touchscreen coordinates to my PC through the USB port to move the mouse cursor. I modified the USBMouse program that came with PBP to send the 4-wire resistive touchscreen coordinates to the PC.

The sub routine "CALIBRATE_TOUCHSCREEN" was actually a way of "converting" the 10-bit ADC reading comming out of the PIC ADC port to the proper pixel coordinates I needed to make the mouse cursor move accross the PC screen. These values were found experimentally, pretty much trial and error. Now, for my 320x240 LCD display with touchscreen I wrote a calibration routine which is a lot more involved than the code that you have above. If you need the code, let me know.

Robert