Created
July 20, 2016 10:44
-
-
Save anonymous/56be996170e2ead4659a03dd25893182 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Touch screen library with X Y and Z (pressure) readings as well | |
| // as oversampling to avoid 'bouncing' | |
| // This demo code returns raw readings, public domain | |
| #include <stdint.h> | |
| #include "TouchScreen.h" | |
| #define YP A2 // must be an analog pin, use "An" notation! | |
| #define XM A3 // must be an analog pin, use "An" notation! | |
| #define YM 8 // can be a digital pin | |
| #define XP 9 // can be a digital pin | |
| // For better pressure precision, we need to know the resistance | |
| // between X+ and X- Use any multimeter to read it | |
| // For the one we're using, its 300 ohms across the X plate | |
| TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300); | |
| void setup(void) { | |
| Serial.begin(9600); | |
| } | |
| void loop(void) { | |
| // a point object holds x y and z coordinates | |
| TSPoint p = ts.getPoint(); | |
| // we have some minimum pressure we consider 'valid' | |
| // pressure of 0 means no pressing! | |
| if (p.z > ts.pressureThreshhold) { | |
| Serial.print("X = "); Serial.print(p.x); | |
| Serial.print("\tY = "); Serial.print(p.y); | |
| Serial.print("\tPressure = "); Serial.println(p.z); | |
| } | |
| delay(100); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment