TOUCHSCREEN interfacing

All of us like touchscreens...better than buttons...be it on mobiles, gaming, ATMs or anywhere else! Now, what if we can use touchscreens and calibrate them according to our requirements? I will talk about resistive touchscreens...a four-wired resistive toucscreen to be more specific.
needless to say, this is my favorite topic :) so a four wire resistive touchscreen is simply a network of resistance. This link provides a simple datasheet about resistive touchscreens
the layers of touchscreen as mentioned in the image are polyester film, top resistive layer, conductive transparent metal coating, bottom resistive layer, insulating dots, glass substrate. When we simply "touch" the two resistive networks come in contact and thus, the electrical circuit is completed. Now, lets see what happens when we "touch" :)
We can name the two resistive layers as X and Y. As i mentioned earlier, its a 4 wired touchscreen. So lets name the wires as X+, X-, Y+ and Y- for the sake of convenience. This can be seen in the image shown below,
left hand side, we have two resistive layers. X & Y (as we named it) which have two wires each, making total of four wires. Now we would calibrate these four wires to interface with the touchscreen. We know that the touch screen is a simple resistive network. So, every small point has a specific value of voltage (of-course when we touch) . How does this happen? Lets find out..
this is the resistive network i was talking about. So if we simply provide input voltage (for sake of clarity lets say 5 volts) at X+ and ground at X-, and if we read voltage value at Y+, we will get X coordinate of the touch! try to think again if u couldn't understand at the first place. Y+ would read a voltage value of 
5{RXb/(RXa+RXb)} - small voltage drop across RYa which can be neglected. Take a minute, think.
This will vary throuhout the "X-axis" of touchscreen from 0 to 5 volts (theoretically, practically it would be little less).
Similarly, providing 5V to Y+, ground to Y- and reading voltage value at X+ will give us Y coordinate of the point of touch.
We have voltage values with us now. What will we do with tis? Simply, send these values to the ADC of a microcontroller. It will convert the analog value of voltage to a digital value. Maybe use a 8-bit ADC so that, X and Y coordinates can be found out easily from (0,0) to (255,255). Now what can we do more? Can we find out when the user is touching and when is he breaking the touch?? Well think about it...think electrically how we cal bug this. Hint is provided in the next image. Also this sums up everything..



also, you might be confused about the wires, so here is the orientation for most of the thoucscreens. I would advise you to check this before hand. Wire type can be easily seen by naked eye as X and Y wires are generally coloured differently.


Wire
1
2
3
4
Type
X+
Y+
X-
Y-


I hope this blog helps everyone interested in working with touchscreens..:)