I have tried increasing the resistance to ground of the two analogRead lines in the circuit, without radical improvement; the issue is that the voltage rapidly drops to zero if, even during contiued contact, pressure is relaxed:
/* TOUCHSCREEN ELECTRODE PAIRS= X1-X2, Y1-Y2
connect as A0=X1, A1=Y1, A2=X2, A3=Y2;
A0 and A1 alternate readings, so 10k pulldown to gnd on these;
'open circuit' floating values cured via digitalWrite to 0v on
A2 and A3
*/
int xVal = 0;
int yVal = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
pinMode(A0, OUTPUT); //analog 0 = gnd;
pinMode(A1, INPUT); //analog 1 = signalRead;
pinMode(A2, OUTPUT); //analog 2 = +5v;
pinMode(A3, INPUT); //switch3
digitalWrite(A0, LOW); //gnd
digitalWrite(A2, HIGH); //+5v
delay(10); //let voltage settle
xVal = analogRead(A1); //read pin 1
xVal/=4;
digitalWrite(A2, LOW); //back to gnd
//switch pinModes to read other axis
pinMode(A0, INPUT); //analog 0 = signalRead
pinMode(A1, OUTPUT); //analog 1 = gnd
pinMode(A2, INPUT); //switch2
pinMode(A3, OUTPUT); //analog 3 = +5v
digitalWrite(A1, LOW); //gnd
digitalWrite(A3, HIGH); //+5v
delay(10);
yVal = analogRead(A0);
yVal/=4;
digitalWrite(A3, LOW); //back to gnd
//send data to Max
Serial.print(xVal, BYTE);
Serial.print(255, BYTE);//punctuation byte
Serial.print(yVal, BYTE);
delay(80);
}
Cheers