Basic Touch Screen– Arduino Workshop

Basic Touch Screen

For this project, We know about Basic Touch Screen  Arduino and you will need a Nintendo DS touch screen as well as a breakout module. The latter is essential as the output from the touch screen is a very thin and fragile ribbon connector, and it will be impossible to interface to the Arduino without additional components.
Required Component

1.Arduino

2. Resistors

3. Nintendo DS touch screen

4. Touch screen breakout

5. connecting wire

6. Breadboard

This book will help you to gain more knowledge about Arduino

Beginning Arduino

Circuit diagram Basic Touch Screen Arduino:

Basic Touch Screen

The breakout unit has pins marked as X1, Y2, X2, and Y1. Connect the pins as described in Table. You will need a connection from the IOREF pin (or 5V pin if you have an older Arduino without an IOREF pin) to the breadboard and then suitably high-value resistors (around 50K) between the X2 and Y1 pins and the IOREF line on the breadboard.

Connect the pins as described in Table
You will need to solder some header pins to the breakout unit. The pins are soldered such that The SparkFun logo is facing upward. The screen is connected to the breakout unit via the small connector. Pull back the tab and push the tiny ribbon cable into the connector, then push the tab closed to lock it in place. The screen goes with the ribbon connector at the top right when connecting. From now on, be very careful with the unit: it is very fragile and easily broken! I broke three screens and two breakouts in testing. If you can find a way of fixing the breadboard, breakout, and touch screen in place to prevent it from moving, you should do so.

Code Basic Touch Screen Arduino:

// Power connections
#define Left 8 // Left (X1) to digital pin 8
#define Bottom 9 // Bottom (Y2) to digital pin 9
#define Right 10 // Right (X2) to digital pin 10
#define Top 11 // Top (Y1) to digital pin 11
// Analog connections
#define topInput 0 // Top (Y1) to analog pin 0
#define rightInput 1 // Right (X2) to analog pin 1
int coordX = 0, coordY = 0;
void setup()
{
Serial.begin(38400);
}
void loop()
{
if (touch()) // If screen touched, print coordinates
{
Serial.print(coordX);
Serial.print(" ");
Serial.println(coordY);
delay(250);
}
}
// return TRUE if touched, and set coordinates to touchX and
touchY
boolean touch()
{
boolean touch = false;
// get horizontal co-ordinates
pinMode(Top, INPUT); // Top and Bottom to high impedance
pinMode(Bottom, INPUT);
pinMode(Left, OUTPUT);
digitalWrite(Left, LOW); // Set Left to low
pinMode(Right, OUTPUT); // Set right to +5v
digitalWrite(Right, HIGH);
delay(3);
coordX = analogRead(topInput);
// get vertical co-ordinates
pinMode(Right, INPUT); // left and right to high impedance
pinMode(Left, INPUT);
pinMode(Bottom, OUTPUT); // set Bottom to Gnd
digitalWrite(Bottom, LOW);
pinMode(Top, OUTPUT); // set Top to +5v
digitalWrite(Top, HIGH);
delay(3);
coordY = analogRead(rightInput);
// if co-ordinates read are less than
1000 and greater than 24
// then the screen has been touched
if(coordX < 1000 && coordX > 24 && coordY < 1000 && coordY >
24) {touch = true;}
return touch;
}

Enter the code and upload it to your Arduino. Once it is running, open up the serial monitor, and then touch the touch screen. Whenever the screen is touched, the coordinates of your finger will be displayed on the serial monitor. The coordinates are x across the horizontal plane going from left to right and y across the vertical plane going from top to bottom

All Arduino tutorial available Click here

 ALL ARDUINO TUTORIAL 

 74 total views,  1 views today