Skip to content

Commit 62f58d4

Browse files
authored
Update TFTEtchASketch.ino
Updated the mapping of signal values from the joystick to the offset coordinates. Fixed screen cleaning.
1 parent 45471a6 commit 62f58d4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

examples/Arduino/TFTEtchASketch/TFTEtchASketch.ino

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ int erasePin = 2;
3939
void setup() {
4040
// declare inputs
4141
pinMode(erasePin, INPUT);
42+
digitalWrite(erasePin, HIGH);
4243
// initialize the screen
4344
TFTscreen.begin();
4445
// make the background black
@@ -51,8 +52,8 @@ void loop() {
5152
int yValue = analogRead(A1);
5253

5354
// map the values and update the position
54-
xPos = xPos + (map(xValue, 0, 1023, 2, -2));
55-
yPos = yPos + (map(yValue, 0, 1023, -2, 2));
55+
xPos = xPos + (map(xValue, 0, 1023, 2, -3));
56+
yPos = yPos + (map(yValue, 0, 1023, -2, 3));
5657

5758
// don't let the point go past the screen edges
5859
if (xPos > 159) {
@@ -75,7 +76,7 @@ void loop() {
7576
TFTscreen.point(xPos, yPos);
7677

7778
// read the value of the pin, and erase the screen if pressed
78-
if (digitalRead(erasePin) == HIGH) {
79+
if (digitalRead(erasePin) == LOW) {
7980
TFTscreen.background(0, 0, 0);
8081
}
8182

0 commit comments

Comments
 (0)