Touch Screen interfacing with Arduino

Resistive touch screen displays are composed of multiple layers that are separated by thin spaces. Pressure applied to the surface of the display by a finger or stylus causes the layers to touch, which completes electrical circuits and tells the device where the user is touching.

In this chapter we are focusing only on 4-wire resistive touch screen interfacing.

Step 1: Components Required

  1. Arduino Board
  2. Touch Screen
  3. Connecting Wires
Components Required for touch screen interfacing with arduino
Components Required for touch screen interfacing with arduino

Step 2: Connections to Arduino

  1. Connect X1 of touch screen to A0 of arduino
  2. Connect X2 to A1 of arduino
  3. Connect Y1 to A2 of arduino
  4. Connect Y2 to A3 of arduino
Touch Screen connections with Arduino
Touch Screen connections with Arduino
Touch Screen connections with Arduino
Touch Screen connections with Arduino

Step 3: Programming the arduino

How it works?

Measure X axis Voltage
Reading X axis touch
Reading X axis touch

To measure X axis voltage

1.We are going to measure voltage on Y1

pinMode(Y1,INPUT);

2. Make Y2 Tristate

pinMode(Y2,INPUT);

digitalWrite(Y2,LOW);

3. Form a voltage divider in X1(+5V) and X2(GND)

pinMode(X1,OUTPUT);

digitalWrite(X1,HIGH);

pinMode(X2,OUTPUT);

digitalWrite(X2,LOW);

4. Read the ADC from Y1 pin

X = (analogRead(Y1))/(1024/XYresolution);

Measure Y axis Voltage

Measure Y axis touch
Measure Y axis touch

To measure Y axis voltage

1.We are going to measure voltage on X1

pinMode(X1,INPUT);

2. Make X2 Tristate

pinMode(X2,INPUT);

digitalWrite(X2,LOW);

3. Form a voltage divider in Y1(+5V) and Y2(GND)

pinMode(Y1,OUTPUT);

digitalWrite(Y1,HIGH);

pinMode(Y2,OUTPUT);

digitalWrite(Y2,LOW);

4. Read the ADC from X1 pin

Y = (analogRead(X1))/(1024/Yresolution);

Arduino Code for Touch Screen Interface

Result

Observe the result on serial monitor. It displays where you have touched on the screen.

Touch screen results
Touch screen results

 

Leave a Reply