Hello,
I would like to control resistive screen through the Pro micro. (4 wire : X+;Y+;X-,Y-)
I have already succeeded in print coordinates where I click on the touch screen in serial monitor but that's it...
I tried many possibilities and read this tutorial Turn your ProMicro into a USB Keyboard/Mouse - SparkFun Electronics without any luck...also this documentation about mouse function Mouse - Arduino Reference.
Here is my code for print coordinates in serial monitor :
/*=================================
This code demostrates 4-Wire Touch screen
interfacing with Arduino
blog.circuits4you.com
www.circuits4you.com
4- Wire Touchscreen Connections
A0=====X+
A1=====X-
A2=====Y+
A3=====Y-
=================================*/
//Define your Touch screen connections
#define X1 A0
#define X2 A1
#define Y1 A2
#define Y2 A3
//Define your screen resolution as per your Touch screen (Max: 1024)
#define Xresolution 1024 //128 //320 //1024
#define Yresolution 600 //64 //240 //600
void setup()
{
Serial.begin(9600);
}
void loop()
{
int X,Y; //Touch Coordinates are stored in X,Y variable
pinMode(Y1,INPUT);
pinMode(Y2,INPUT);
digitalWrite(Y2,LOW);
pinMode(X1,OUTPUT);
digitalWrite(X1,HIGH);
pinMode(X2,OUTPUT);
digitalWrite(X2,LOW);
X = (analogRead(Y1))/(1024/Xresolution); //Reads X axis touch position
pinMode(X1,INPUT);
pinMode(X2,INPUT);
digitalWrite(X2,LOW);
pinMode(Y1,OUTPUT);
digitalWrite(Y1,HIGH);
pinMode(Y2,OUTPUT);
digitalWrite(Y2,LOW);
Y = (analogRead(X1))/(1024/Yresolution); //Reads Y axis touch position
//Display X and Y on Serial Monitor
Serial.print("X = ");
Serial.print(X);
Serial.print(" Y = ");
Serial.println(Y);
delay(100);
}