Designing an Infinite Sawtooth Design Loop

Hi guys,

So I’m working on making an Arduino Uno produce an infinitely looping sawtooth design. I want to be able to pull up the serial plotter and have the line displayed there.

However, I do believe that my problem lies within the error “‘screen’ was not declared in this scope”. I’m new to Arduino/C++ coding so I don’t quite know what this means and googling does not seem to help for my problem either.

As of right now, my code seems to be infinitely increasing, instead of dropping back down to 0 after 250 units. The highlighted line is number 17, the first “screen.line.”

My error lines (below the coding window, whatever this is called) has the following:

In file included from C:\Users\Connor\Desktop\Arduino\libraries\TFT\src/TFT.h:36:0,

from C:\Users\Connor\Desktop\Sawtooth_Design\Sawtooth_Design.ino:1:

C:\Users\Connor\Desktop\Arduino\libraries\TFT\src/utility/Adafruit_GFX.h:60:3: warning: #warning “The SD library was not found. loadImage() and image() won’t be supported.” [-Wcpp]

#warning “The SD library was not found. loadImage() and image() won’t be supported.”

^

C:\Users\Connor\Desktop\Sawtooth_Design\Sawtooth_Design.ino:19:0: warning: “x_dimension” redefined

#define x_dimension new_x_dimension //defines the first x-point as the second x-point from this loop

^

C:\Users\Connor\Desktop\Sawtooth_Design\Sawtooth_Design.ino:10:0: note: this is the location of the previous definition

#define x_dimension 0 //set the original x-point to 0

^

C:\Users\Connor\Desktop\Sawtooth_Design\Sawtooth_Design.ino: In function ‘void loop()’:

Sawtooth_Design:17: error: ‘screen’ was not declared in this scope

screen.line(x_dimension,0,new_x_dimension,250); //Draws a line with a slope of +1

^

exit status 1
‘screen’ was not declared in this scope

I believe that I attached my code below. I first learned to program in Matlab, so it may be that I am trying to make it work like Matlab, even though it is Arduino. Any help would be greatly appreciated!

Thanks!

Sawtooth_Design.ino (758 Bytes)

I believe that I attached my code below.

I believe that you should have POSTED YOUR CODE

#include "TFT.h"
#include "SPI.h"

void setup() {
  // put your setup code here, to run once:
TFT screen = TFT(10, 9, 8);
screen.begin(); //this sets the screen up to draw a sawtooth (or any line/design)
screen.background(255,255,255); //Background is white
screen.stroke(0,0,0); //Line is black
#define x_dimension 0 //set the original x-point to 0

}

void loop() {
  // put your main code here, to run repeatedly:
#define new_x_dimension x_dimension+250 //make the new x-point to 250 more than the last
screen.line(x_dimension,0,new_x_dimension,250); //Draws a line with a slope of +1
screen.line(250,250,250,0); //Brings the line back to the x-axis
#define x_dimension new_x_dimension  //defines the first x-point as the second x-point from this loop
}

'screen' is declared inside setup() so it is local to that function and can't be seen by other functions. You probably intended to make 'screen' global. To do that, move the declaration to above setup().

You can't use "#define" to assign values to variables. Use the assignment operator '=' instead.