Hi, I have two Arduino Mega boards:
- ARDUINO MEGA 2560 R3 ATmega 2560
- MEGA2560 ATmega 2560 CH340 ARDUINO
I don't know if they are the same boards but the second were cheaper and the same seller has two of them.
When I run simple example from Utouch board 1) works fine, board 2) behaves upredicteably.
void setup()
{
Serial.begin(9600);
Serial.println("*******");
myTouch.InitTouch(PORTRAIT);
myTouch.setPrecision(PREC_MEDIUM);
}
void loop()
{
while (true)
{
if (myTouch.dataAvailable())
{
myTouch.read();
x=myTouch.getX();
y=myTouch.getY();
Serial.println(x);
Serial.println(y);
Serial.println("*******");
}
}
}
I started playing with /hardware/*/inc files:
word UTouch::touch_ReadData()
{
word data = 0;
for(byte count=0; count<12; count++)
{
data <<= 1;
digitalWrite(T_CLK, HIGH);
delayMicroseconds(200); //// added to get more stable readings???
digitalWrite(T_CLK, LOW);
delayMicroseconds(200); //// added to get more stable readings???
if (digitalRead(T_DOUT))
data++;
}
return(data);
Coordinates are more accurate.
After some touching it breaks down (after some touching it always points -1, -1):
(29, 49)
(36, 46)
(-1, -1)
(31, 37)
(-1, -1)
(-1, -1)
(43, 292)
(-1, -1)
(21, 284)
(-1, -1)
(19, 282)
(-1, -1)
(15, 284)
(-1, -1)
(140, 280)
(141, 277)
(155, 302)
(-1, -1)
(-1, -1)
(-1, -1)
(-1, -1)
(-1, -1)
(-1, -1)
(-1, -1)
(-1, -1)
(-1, -1)
(-1, -1)
(-1, -1)
(-1, -1)
(138, 33)
(-1, -1)
(-1, -1)
(-1, -1)
(-1, -1)
(136, 36)
(-1, -1)
(138, 37)
(135, 34)
(137, 38)
(-1, -1)
(135, 38)
(-1, -1)
(138, 37)
(-1, -1)
(137, 35)
(-1, -1)
(-1, -1)
(-1, -1)
(-1, -1)
(132, 260)
(-1, -1)
(-1, -1)
(-1, -1)
(-1, -1)
(-1, -1)
(-1, -1)
(...... endless -1, -1) no matter when I touch it