Hi,
I'm using arduino leonardo to interface the Nintendo ds touch screen (https://www.sparkfun.com/products/8977)
I used this example as starting point:
http://kalshagar.wikispaces.com/Arduino+and+a+Nintendo+DS+touch+screen
I connected the touch screen in the fallowing way:
Y1 - A2
X2 - A1
Y2 - A0
X1 - A3
I use this two functions to read X and Y:
int readX() // returns the value of the touch screen's X-axis
{
int xr=0;
pinMode(A0, INPUT); // A0
pinMode(A1, OUTPUT); // A1
pinMode(A2, INPUT); // A2
pinMode(A3, OUTPUT); // A3
digitalWrite(A1, LOW); // set A1 to GND
digitalWrite(A3, HIGH); // set A3 as 5V
delay(5); // short delay is required to give the analog pins time to adjust to their new roles
xr=analogRead(A2);
return xr;
}
int readY() // returns the value of the touch screen's Y-axis
{
int yr=0;
pinMode(A0, OUTPUT); // A0
pinMode(A1, INPUT); // A1
pinMode(A2, OUTPUT); // A2
pinMode(A3, INPUT); // A3
digitalWrite(A0, LOW); // set A0 to GND
digitalWrite(A2, HIGH); // set A2 as 5V
delay(5); // short delay is required to give the analog pins time to adjust to their new roles
yr=analogRead(A1);
return yr;
}
The problem is that I get this intervals when readin X and Y:
y= [150,740]
x=[100,470]
Why is the interval on x smaller the on Y axis if the resistance on X axis is 624 and on Y axis is 300 and something ?