I'm having trouble getting accurate readings on my resistive touchscreen. I'm using a DS touchscreen from Sparkfun and the breakout board for the connector also from Sparkfun. I'm using an old Bare Bones Board from Modern Device with a 168.
I know I'm driving the screen correctly. I'm getting somewhat accurate readings but it seems that I don't get full resolution. The lowest coordinates I can see are about 70,123 (x,y respectively) while the highest I can see are about 900,850. I have y1 connected to digital pin 14, x2 to digital pin 15, y2 to digital pin 16, and x1 to digital pin 17. I have weak pulldowns of 39K on each pin. Don't ask me why I'm doing this. In my mind, this would seem to create a voltage divider on the inputs when doing an analogRead of the screen but it seems to increase my resolution when I do it (does that mean my high impedance inputs aren't as high impedance as I need them to be?) I saw an example somewhere that used 10K resistors but I only have three of those right now so I went for something a bit weaker that I had more of.
I'm trying to get the full 0-1023 range from this screen. What am I doing wrong?
Here's the part of my code relevant to reading the screen:
//define touchscreen pins
#define y1 14 //A0
#define x2 15 //A1
#define y2 16 //A2
#define x1 17 //A3
#define xRead A2
#define yRead A3
unsigned int posX = 0;
unsigned int posY = 0;
inline void touchCheck()
{
//read X coord
pinMode(x1, OUTPUT);
pinMode(x2, OUTPUT);
digitalWrite(x1, LOW);
digitalWrite(x2, HIGH);
pinMode(y1, INPUT);
pinMode(y2, INPUT);
digitalWrite(y1, LOW);
digitalWrite(y2, LOW);
delay(5);
posX = analogRead(xRead);
delay(5);
//read Y coord
pinMode(x1, INPUT);
pinMode(x2, INPUT);
digitalWrite(x1, LOW);
digitalWrite(x1, LOW);
pinMode(y1, OUTPUT);
pinMode(y2, OUTPUT);
digitalWrite(y1, HIGH);
digitalWrite(y2, LOW);
delay(5);
posY = analogRead(yRead);
delay(5);
}
void loop()
{
touchCheck();
Serial.print(posX);
Serial.print(",");
Serial.println(posY);
}
I'm inclined to believe this is a hardware problem, not a software one but, based on what I've seen in other examples, what I have SHOULD work.
Any help would be much appreciated.