add arduino test sketch for touchscreen reading
This commit is contained in:
parent
de9f3bf1b3
commit
5253fdd58c
38
tests/arduino_touchscreen_test/arduino_touchscreen_test.ino
Normal file
38
tests/arduino_touchscreen_test/arduino_touchscreen_test.ino
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
void setup() {
|
||||||
|
// put your setup code here, to run once:
|
||||||
|
Serial.begin(9600);
|
||||||
|
Serial.println("\"setup\"");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class Panel {
|
||||||
|
int A,B;
|
||||||
|
public:
|
||||||
|
Panel(int one, int two) : A(one), B(two) {
|
||||||
|
pinMode(A, OUTPUT);
|
||||||
|
pinMode(B, OUTPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
int Y() {
|
||||||
|
digitalWrite(A, 1);
|
||||||
|
int result = analogRead(B);
|
||||||
|
digitalWrite(A, 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int X() {
|
||||||
|
digitalWrite(B, 1);
|
||||||
|
int result = analogRead(A);
|
||||||
|
digitalWrite(B, 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
} panel(A0,A1);
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
// put your main code here, to run repeatedly:
|
||||||
|
Serial.print(panel.X());
|
||||||
|
Serial.print("\t");
|
||||||
|
Serial.println(panel.Y());
|
||||||
|
delay(100);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user