This code is for a 4 -wire resistive touch panel . Iam not understanding why everytime port 14 is used for reading ? If i understand correctly the working of a 4-wire resisitve touch panel then we have to first apply voltage to X - axis and read off Y an then apply voltage to Y axis and read off X.
I got this code ihere from the arduino forum.
thanks
// Taken from http://kousaku-kousaku.blogspot.com/2008/08/arduino_24.html
/*
#define xLow 14
#define xHigh 15
#define yLow 16
#define yHigh 17
*/
//modified to match my sparkfun connector
#define xLow 17
#define xHigh 15
#define yLow 16
#define yHigh 14
void setup(){
Serial.begin(9600);
}
void loop(){
pinMode(xLow,OUTPUT);
pinMode(xHigh,OUTPUT);
digitalWrite(xLow,LOW);
digitalWrite(xHigh,HIGH);
digitalWrite(yLow,LOW);
digitalWrite(yHigh,LOW);
pinMode(yLow,INPUT);
pinMode(yHigh,INPUT);
delay(10);
//xLow has analog port -14 !!
int x=analogRead(yLow -14);
pinMode(yLow,OUTPUT);
pinMode(yHigh,OUTPUT);
digitalWrite(yLow,LOW);
digitalWrite(yHigh,HIGH);
digitalWrite(xLow,LOW);
digitalWrite(xHigh,LOW);
pinMode(xLow,INPUT);
pinMode(xHigh,INPUT);
delay(10);
//xLow has analog port -14 !!
int y=analogRead(xLow - 14);
Serial.print(x,DEC);
Serial.print(",");
Serial.println(y,DEC);
delay(200);
}