Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions examples/Arduino/TFTEtchASketch/TFTEtchASketch.ino
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ int erasePin = 2;
void setup() {
// declare inputs
pinMode(erasePin, INPUT);
digitalWrite(erasePin, HIGH);
// initialize the screen
TFTscreen.begin();
// make the background black
Expand All @@ -51,8 +52,8 @@ void loop() {
int yValue = analogRead(A1);

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

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

// read the value of the pin, and erase the screen if pressed
if (digitalRead(erasePin) == HIGH) {
if (digitalRead(erasePin) == LOW) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (digitalRead(erasePin) == LOW) {

See explanation above.

TFTscreen.background(0, 0, 0);
}

Expand Down