4-Wire Touch Screen Interfacing With Arduino

About: Electronic store www.circuits4you.com Design Ideas blog.circuits4you.com Industry www.maventech.in Software fun www.360motions.com

For more stuff visit my web site Steps2Make.com

This tutorial shows How to interface 4-wire touch screen using Arduino. This tutorial is useful for all microcontrollers to know how to interface Reisistive Touchscreen

Resistive touchscreen 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.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Components Required and Connections

Components Required:

  1. Touchscreen
  2. Arduino UNO R3
  3. Connecting wires

Tools Required:

  1. Laptop with arduino software
  2. USB cable for arduino

Make Connections:

  1. Connect X1 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

Visit my blog.circuits4you.com for step by step guide and more sensors interfacing with arduino

Step 2: How It Works ? and Programming

It works in 2 steps

Measure X axis Voltage

a. We are going to measure voltage on Y1

pinMode(Y1,INPUT);

b. Make Y2 Tristate

pinMode(Y2,INPUT);

digitalWrite(Y2,LOW);

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

pinMode(X1,OUTPUT); digitalWrite(X1,HIGH);

pinMode(X2,OUTPUT); digitalWrite(X2,LOW);

d. Read the ADC from Y1 pin

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

Similarly Measure Y axis Voltage

a. We are going to measure voltage on X1

pinMode(X1,INPUT);

b. Make X2 Tristate

pinMode(X2,INPUT);

digitalWrite(X2,LOW);

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

pinMode(Y1,OUTPUT);

digitalWrite(Y1,HIGH);

pinMode(Y2,OUTPUT);

digitalWrite(Y2,LOW);

d. Read the ADC from X1 pin

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

Download Code from here

Step 3: Final Output and Testing

Load the code in arduino and See the results in Serial Monitor

Be the First to Share

    Recommendations

    • CNC Contest

      CNC Contest
    • Make it Move

      Make it Move
    • Teacher Contest

      Teacher Contest

    15 Discussions

    0
    None
    ksky6853350

    4 months ago

    should i buy resistive touch screen controller?
    i already bought arduino then i don't need to buy additional controller??
    and i want to know the model name of screen~~

    1
    None
    berin

    4 months ago

    JUST AN FYI for anyone getting scope errors when compiling there is an error in the guys code he links to. where he defines pins they are written ass backwards in the code on the page (#define A0 X1 is worng it reads define A0 a name, to pin X1 there is no pin X1). In the loop () when pinMode(X1,OUTPUT); tries to set the pin mode of a0 its looking for X1 but was instead defined as A0. Below is the correction. You can read the declaration as "#define NAME to pin X" in the correction below it is "#define X1-an easy name to define its function assignment to A0 a pin assignment on the arduino analog pin 0

    //Define your Touch screen connections
    #define X1 A0
    #define X2 A1
    #define Y1 A2
    #define Y2 A3

    1
    None
    JihadS2

    Tip 6 months ago

    People who are having faulty readings please follow the following tips:
    - First of all, make sure you have Two big Pull down resistors on the Two analog inputs. ( I used 10Kohms ) . it is not shown that he used any but you certainly need resistors.
    - Second, there is a mistake in his code. the delay commands should be placed before analogRead commands to give the arduino the time to switch the pinmodes. if you put the delay command before after the analogRead you will not have a 0 value with no touch and also your readings will be totally wrong.

    0
    None
    GurtejS4

    Question 1 year ago on Step 3

    I have interfaced touch screen and arduino . But when we touch , it display a large no. of input . Can’t it be like , if i touch once and i get one value for x and y?

    0
    None
    techy06

    2 years ago

    how can i sense a letter if drawn.for ex if i draw the letter h,how am i suppose to code to find those coordinates wherever i touhed

    Thanks in advance

    1 reply
    0
    None
    Orngrimmtechy06

    Reply 1 year ago

    The 'ible shows you how to find your position:

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

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

    Now it is your code to programm to detect (?) what letter it represents. Quite hard to do. Thats OCR (Optical Character recognition) and may be beyond the capabilities of a normal coder... and calc-power of an arduino (?)

    0
    None
    OrngrimmFreelanceCody

    Reply 1 year ago

    I sourced dirt cheap from Pollin.de

    Also, Aliexpress has cheap ones in all possible sizes...

    0
    None
    Orngrimmrshouker

    Reply 1 year ago

    Setting it as input and setting it afterwards to LOW results in a completely open pin --> TRI-State.

    Yes, It is possible that the pull-R's are disabled by default. But as it is quite fast to do, better be safe than sorry ;)

    0
    None
    LucianoL26

    2 years ago

    Thats amazing! could it be used like a drawing tablet?

    0
    None
    PrisNaboo

    2 years ago

    Hey! This is very cool, just one question. When you don't touch the touchscreen, does the value come to 0?

    Sorry if my english is not good, I'm a Belgian ;)

    Thanks to you!

    1 reply
    0
    None
    stephenplace17PrisNaboo

    Reply 2 years ago

    No, you have a floating results and can't get anything meaningful...to solve this problem is enough to put pulldown resistors (10Kohm) in every output (one terminal of the resistor to GND and the other to the touch contact).

    0
    None
    Bladder777

    3 years ago

    hi, i have 5 wire outlet....what would that mean? multitouch?

    1 reply
    0
    None
    chansesBladder777

    Reply 3 years ago

    i hope you have found your answer, but no usually a 5-wire resistive touch screen is not multi touch. it just is a different way of building the screen.

    here is a link to a very helpfull page on how the two work.

    http://www.dmccoltd.com/english/museum/touchscreen...

    hope it helps you or someone else who makes it to this page