Hi
novice programmer would very much welcome tips on how to 'de-jitter' noisy touch panel voltages:
using a stylus gives clean sharp repeatable voltages (I'm using the standard circuit for hacking these: pwr/gnd to one axis pair, read from one of the other, then invert and repeat for the other axis); using a finger causes 'ramp up' on contact, 'ramp down' on release. ie can someone recommend a method for averaging that isn't too slow. Here's my code
/* TOUCHSCREEN ELECTRODE PAIRS= X1-X2, Y1-Y2
connect as A0=X1, A1=Y1, A2=X2, A3=Y2;
A0 and A1 alternate readings, so 1k 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()//first axis cycle
{
pinMode(A0, OUTPUT); //analog 0 = gnd;
pinMode(A2, OUTPUT); //analog 2 = +5v;
pinMode(A1, INPUT); //analog 1 = signalRead;
pinMode(A3, INPUT); //switch3
digitalWrite(A0, LOW); //gnd
digitalWrite(A2, HIGH); //+5v
delay(5); //let voltage settle
xVal = analogRead(A1); //read pin 1
xVal/=4; //0-1024 = 0-128
digitalWrite(A2, LOW); //back to gnd
//switch pinModes to read other axis
pinMode(A3, OUTPUT); //analog 3 = +5v
pinMode(A1, OUTPUT); //analog 1 = gnd
pinMode(A2, INPUT); //switch2
pinMode(A0, INPUT); //analog 0 = signalRead
digitalWrite(A1, LOW); //gnd
digitalWrite(A3, HIGH); //+5v
delay(5);
yVal = analogRead(A0);
yVal/=4;
digitalWrite(A3, LOW); //back to gnd
//either monitor, or send to Max
//Serial.print("X= ");
Serial.print(xVal,BYTE);
//Serial.print("\t\tY= ");
Serial.print(yVal,BYTE);
Serial.print(255, BYTE);
delay (40);
}
n00bmeister
ps, can I get email notifications on this forum somehow?