Sketch not running

I am pretty much brand new at this. I am trying to run a sketch that flashes various LEDs and also runs a OLED screen. I can separate them and do just the LEDs or just the OLED screen. But obviously since I'm here and not in the bedroom with my wife, I am having a hell of a time getting them to work together.

The errors Im getting are as follows
C:\Users\Jolene\AppData\Local\Temp\ccapSHuO.ltrans0.ltrans.o: In function main': C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:46: undefined reference to loop'
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Mega or Mega 2560.

the sketch Im running is
// Screen dimensions
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 128 // Change this to 96 for 1.27" OLED.
// You can use any (4 or) 5 pins
#define SCLK_PIN 37
#define MOSI_PIN 39
#define DC_PIN 35
#define CS_PIN 31
#define RST_PIN 33

// Color definitions
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1351.h>
#include <SPI.h>
#include <Arduino.h>

// Option 1: use any pins but a little slower
Adafruit_SSD1351 tft = Adafruit_SSD1351(SCREEN_WIDTH, SCREEN_HEIGHT, CS_PIN, DC_PIN, MOSI_PIN, SCLK_PIN, RST_PIN);

// Option 2: must use the hardware SPI pins
// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be
// an output. This is much faster - also required if you want
// to use the microSD card (see the image drawing example)
//Adafruit_SSD1351 tft = Adafruit_SSD1351(SCREEN_WIDTH, SCREEN_HEIGHT, &SPI, CS_PIN, DC_PIN, RST_PIN);

float p = 3.1415926;

int led04 = 04; // the PWM pin the LED is attached to
int led05 = 05; // the PWM pin the LED is attached to
int led06 = 06; // the PWM pin the LED is attached to
int led07 = 07; // the PWM pin the LED is attached to
int led2 = 2; // the PWM pin the LED is attached to
int led3 = 3; // the PWM pin the LED is attached to
int led10 = 10; // the PWM pin the LED is attached to
int brightness4 = 75; // how bright the c white LED is
int fadeAmount4 = 0; // how many points to fade the c white LED by
int brightness5 = 2; // how bright the yellow LED is
int fadeAmount5 = 6; // how many points to fade the yellow LED by
int brightness6 = 4; // how bright the red LED is
int fadeAmount6 = 2; // how many points to fade the red LED by
int brightness7 = 6; // how bright the green LED is
int fadeAmount7 = 3; // how many points to fade the green LED by
int brightness2 = 5; // how bright the blue LED is
int fadeAmount2 = 5; // how many points to fade the blue LED by
int brightness3 = 210; // how bright the b white LED is
int fadeAmount3 = 178; // how many points to fade the b white LED by
int brightness10 = 5; // how bright the red LED is
int fadeAmount10 = 17; // how many points to fade the red LED by
int randNumber;
int PrintTest;

// the setup routine runs once when you press reset:

void setup(){
// declare pin 04 to be an output:
pinMode(led04, OUTPUT);
// declare pin 05 to be an output:
pinMode(led05, OUTPUT);
// declare pin 06 to be an output:
pinMode(led06, OUTPUT);
// declare pin 07 to be an output:
pinMode(led07, OUTPUT);
// declare pin 02 to be an output:
pinMode(led2, OUTPUT);
// declare pin 03 to be an output:
pinMode(led3, OUTPUT);
// declare pin 10 to be an output:
pinMode(led10, OUTPUT);

void setup(void);
Serial.begin(9600);
Serial.print("hello!");
tft.begin();

Serial.println("init");
uint16_t time = millis();
tft.fillRect(0, 0, 128, 128, BLACK);
time = millis() - time;

Serial.println(time, DEC);
delay(500);

tft.invert(true);
delay(100);
tft.invert(false);
delay(100);

//a single pixel
tft.drawPixel(tft.width()/2, tft.height()/2, GREEN);
delay(500);

// line draw test
testlines(YELLOW);
delay(500);

// optimized lines
testfastlines(RED, BLUE);
delay(500);

testdrawrects(GREEN);
delay(1000);

testfillrects(YELLOW, MAGENTA);
delay(1000);

tft.fillScreen(BLACK);
testfillcircles(10, BLUE);
testdrawcircles(10, WHITE);
delay(1000);

testroundrects();
delay(500);

testtriangles();
delay(500);

Serial.print("done!");
delay(500);
}
void testlines(uint16_t color) {
tft.fillScreen(BLACK);
for (uint16_t x=0; x < tft.width()-1; x+=6) {
tft.drawLine(0, 0, x, tft.height()-1, color);
}
for (uint16_t y=0; y < tft.height()-1; y+=6) {
tft.drawLine(0, 0, tft.width()-1, y, color);
}

tft.fillScreen(BLACK);
for (uint16_t x=0; x < tft.width()-1; x+=6) {
tft.drawLine(tft.width()-1, 0, x, tft.height()-1, color);
}
for (uint16_t y=0; y < tft.height()-1; y+=6) {
tft.drawLine(tft.width()-1, 0, 0, y, color);
}

tft.fillScreen(BLACK);
for (uint16_t x=0; x < tft.width()-1; x+=6) {
tft.drawLine(0, tft.height()-1, x, 0, color);
}
for (uint16_t y=0; y < tft.height()-1; y+=6) {
tft.drawLine(0, tft.height()-1, tft.width()-1, y, color);
}

tft.fillScreen(BLACK);
for (uint16_t x=0; x < tft.width()-1; x+=6) {
tft.drawLine(tft.width()-1, tft.height()-1, x, 0, color);
}
for (uint16_t y=0; y < tft.height()-1; y+=6) {
tft.drawLine(tft.width()-1, tft.height()-1, 0, y, color);
}

}

void testdrawtext(char *text, uint16_t color) {
tft.setCursor(0,0);
tft.setTextColor(color);
tft.print(text);
}

void testfastlines(uint16_t color1, uint16_t color2) {
tft.fillScreen(BLACK);
for (uint16_t y=0; y < tft.height()-1; y+=5) {
tft.drawFastHLine(0, y, tft.width()-1, color1);
}
for (uint16_t x=0; x < tft.width()-1; x+=5) {
tft.drawFastVLine(x, 0, tft.height()-1, color2);
}
}

void testdrawrects(uint16_t color) {
tft.fillScreen(BLACK);
for (uint16_t x=0; x < tft.height()-1; x+=6) {
tft.drawRect((tft.width()-1)/2 -x/2, (tft.height()-1)/2 -x/2 , x, x, color);
}
}

void testfillrects(uint16_t color1, uint16_t color2) {
tft.fillScreen(BLACK);
for (uint16_t x=tft.height()-1; x > 6; x-=6) {
tft.fillRect((tft.width()-1)/2 -x/2, (tft.height()-1)/2 -x/2 , x, x, color1);
tft.drawRect((tft.width()-1)/2 -x/2, (tft.height()-1)/2 -x/2 , x, x, color2);
}
}

void testfillcircles(uint8_t radius, uint16_t color)
{
for (uint8_t x=radius; x < tft.width()-1; x+=radius2) {
for (uint8_t y=radius; y < tft.height()-1; y+=radius
2) {
tft.fillCircle(x, y, radius, color);
}
}
}

void testdrawcircles(uint8_t radius, uint16_t color) {
for (uint8_t x=0; x < tft.width()-1+radius; x+=radius2) {
for (uint8_t y=0; y < tft.height()-1+radius; y+=radius
2) {
tft.drawCircle(x, y, radius, color);
}
}
}

void testtriangles() {
tft.fillScreen(BLACK);
int color = 0xF800;
int t;
int w = tft.width()/2;
int x = tft.height();
int y = 0;
int z = tft.width();
for(t = 0 ; t <= 15; t+=1) {
tft.drawTriangle(w, y, y, x, z, x, color);
x-=4;
y+=4;
z-=4;
color+=100;
}
}

void testroundrects() {
tft.fillScreen(BLACK);
int color = 100;

int x = 0;
int y = 0;
int w = tft.width();
int h = tft.height();
for(int i = 0 ; i <= 24; i++) {
tft.drawRoundRect(x, y, w, h, 5, color);
x+=2;
y+=3;
w-=4;
h-=6;
color+=1100;
Serial.println(i);
}

void tftPrintTest();
{
tft.fillScreen(BLACK);
tft.setCursor(0, 5);
tft.setTextColor(RED);
tft.setTextSize(1);
tft.println("Hello World!");
tft.setTextColor(YELLOW);
tft.setTextSize(2);
tft.println("Hello World!");
tft.setTextColor(BLUE);
tft.setTextSize(3);
tft.print(1234.567);
delay(1500);
tft.setCursor(0, 5);
tft.fillScreen(BLACK);
tft.setTextColor(WHITE);
tft.setTextSize(0);
tft.println("Hello World!");
tft.setTextSize(1);
tft.setTextColor(GREEN);
tft.print(p, 6);
tft.println(" Want pi?");
tft.println(" ");
tft.print(8675309, HEX); // print 8,675,309 out in HEX!
tft.println(" Print HEX!");
tft.println(" ");
tft.setTextColor(WHITE);
tft.println("Sketch has been");
tft.println("running for: ");
tft.setTextColor(MAGENTA);
tft.print(millis() / 1000);
tft.setTextColor(WHITE);
tft.print(" seconds.");
}
//
/*!
@brief Renders a simple test pattern on the screen
*/
/
/
void lcdTestPattern(void);
{
static const uint16_t PROGMEM colors =
{ RED, YELLOW, GREEN, CYAN, BLUE, MAGENTA, BLACK, WHITE };

for(uint8_t c=0; c<8; c++) {
tft.fillRect(0, tft.height() * c / 8, tft.width(), tft.height() / 8,
pgm_read_word(&colors[c]));

void loop();
{
// set the brightness of pins:
analogWrite(led04, brightness4);
analogWrite(led05, brightness5);
analogWrite(led06, brightness6);
analogWrite(led07, brightness7);
analogWrite(led2, brightness2);
analogWrite(led3, brightness3);
analogWrite(led10, brightness10);

// change the brightness for next time through the loop:
brightness4 = brightness4 + fadeAmount4;
brightness5 = brightness5 + fadeAmount5;
brightness6 = brightness6 + fadeAmount6;
brightness7 = brightness7 + fadeAmount7;
brightness2 = brightness2 + fadeAmount2;
brightness3 = brightness3 + fadeAmount3;
brightness10 = brightness10 + fadeAmount10;

}

// reverse the direction of the fading at the ends of the fade:
if (brightness4 <= 0 || brightness4 >= 250) {
fadeAmount4 = -fadeAmount4;
}
// reverse the direction of the fading at the ends of the fade:
if (brightness4 <= 0 || brightness4 >= 250) {
fadeAmount4 = -fadeAmount4;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
//Blinking white LED randomizer
digitalWrite(led3, !digitalRead(led3)); // turn the LED on/off
randNumber = random(15, 25);

//wait for randomizer

delay(random(20,20));

} }

PLEASE HELP LOL

What is wrong? Edit - oh, the compile errors. Sorry, never mind...

The first thing you should do is AUTO FORMAT your code.. that will highlight some serious structural issues.

Then, turn on full error reporting in the IDE Preferences, when you compile, it will list several places there are questionable syntax.

It looks like you’ve tried to merge your two working ‘test’ programs.
That rarely works.
You might need to go back a step, and understand how those two operate internally, and why they are written the way they are.

When you post code, please follow the forum guides.

The linker is saying that you don't have a function named loop(). That's because you put a ';' between the declaration and the definition:

void loop();
{
  // set the brightness of pins:

Remove that ';'.

You are also missing a '}' at the end of testroundrects(). And two more at the end of lcdTestPattern(). And you have some extra '}' inside loop(). And you try to start setup() twice.

I don't have the Adafruit_SSD1351 library installed so I don't know if fixing those glaring syntax errors will get it to compile but I would not hold out much hope.

If you post your code as described in How to get the best out of this forum, more forum members will read it.

You have brace mismatches. For example tftPrintTest is defined inside of testroundrects. That can't work.

Use the autoformat (CTRL-T) function in the IDE and you will see your brace {} mismatches.

I have run auto format countless times only thing that i see different is that it now states autoformat done

Please post the code again. Properly this time.

If I can figure that out I will. LOL

Hi, @fng001
Your code posted in post #1 with AutoFormat and code tags.

// Screen dimensions
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 128 // Change this to 96 for 1.27" OLED.
// You can use any (4 or) 5 pins
#define SCLK_PIN 37
#define MOSI_PIN 39
#define DC_PIN 35
#define CS_PIN 31
#define RST_PIN 33

// Color definitions
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1351.h>
#include <SPI.h>
#include <Arduino.h>

// Option 1: use any pins but a little slower
Adafruit_SSD1351 tft = Adafruit_SSD1351(SCREEN_WIDTH, SCREEN_HEIGHT, CS_PIN, DC_PIN, MOSI_PIN, SCLK_PIN, RST_PIN);

// Option 2: must use the hardware SPI pins
// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be
// an output. This is much faster - also required if you want
// to use the microSD card (see the image drawing example)
//Adafruit_SSD1351 tft = Adafruit_SSD1351(SCREEN_WIDTH, SCREEN_HEIGHT, &SPI, CS_PIN, DC_PIN, RST_PIN);

float p = 3.1415926;

int led04 = 04; // the PWM pin the LED is attached to
int led05 = 05; // the PWM pin the LED is attached to
int led06 = 06; // the PWM pin the LED is attached to
int led07 = 07; // the PWM pin the LED is attached to
int led2 = 2; // the PWM pin the LED is attached to
int led3 = 3; // the PWM pin the LED is attached to
int led10 = 10; // the PWM pin the LED is attached to
int brightness4 = 75; // how bright the c white LED is
int fadeAmount4 = 0; // how many points to fade the c white LED by
int brightness5 = 2; // how bright the yellow LED is
int fadeAmount5 = 6; // how many points to fade the yellow LED by
int brightness6 = 4; // how bright the red LED is
int fadeAmount6 = 2; // how many points to fade the red LED by
int brightness7 = 6; // how bright the green LED is
int fadeAmount7 = 3; // how many points to fade the green LED by
int brightness2 = 5; // how bright the blue LED is
int fadeAmount2 = 5; // how many points to fade the blue LED by
int brightness3 = 210; // how bright the b white LED is
int fadeAmount3 = 178; // how many points to fade the b white LED by
int brightness10 = 5; // how bright the red LED is
int fadeAmount10 = 17; // how many points to fade the red LED by
int randNumber;
int PrintTest;

// the setup routine runs once when you press reset:

void setup() {
  // declare pin 04 to be an output:
  pinMode(led04, OUTPUT);
  // declare pin 05 to be an output:
  pinMode(led05, OUTPUT);
  // declare pin 06 to be an output:
  pinMode(led06, OUTPUT);
  // declare pin 07 to be an output:
  pinMode(led07, OUTPUT);
  // declare pin 02 to be an output:
  pinMode(led2, OUTPUT);
  // declare pin 03 to be an output:
  pinMode(led3, OUTPUT);
  // declare pin 10 to be an output:
  pinMode(led10, OUTPUT);

  void setup(void);
  Serial.begin(9600);
  Serial.print("hello!");
  tft.begin();

  Serial.println("init");
  uint16_t time = millis();
  tft.fillRect(0, 0, 128, 128, BLACK);
  time = millis() - time;

  Serial.println(time, DEC);
  delay(500);

  tft.invert(true);
  delay(100);
  tft.invert(false);
  delay(100);

  //a single pixel
  tft.drawPixel(tft.width() / 2, tft.height() / 2, GREEN);
  delay(500);

  // line draw test
  testlines(YELLOW);
  delay(500);

  // optimized lines
  testfastlines(RED, BLUE);
  delay(500);

  testdrawrects(GREEN);
  delay(1000);

  testfillrects(YELLOW, MAGENTA);
  delay(1000);

  tft.fillScreen(BLACK);
  testfillcircles(10, BLUE);
  testdrawcircles(10, WHITE);
  delay(1000);

  testroundrects();
  delay(500);

  testtriangles();
  delay(500);

  Serial.print("done!");
  delay(500);
}
void testlines(uint16_t color) {
  tft.fillScreen(BLACK);
  for (uint16_t x = 0; x < tft.width() - 1; x += 6) {
    tft.drawLine(0, 0, x, tft.height() - 1, color);
  }
  for (uint16_t y = 0; y < tft.height() - 1; y += 6) {
    tft.drawLine(0, 0, tft.width() - 1, y, color);
  }

  tft.fillScreen(BLACK);
  for (uint16_t x = 0; x < tft.width() - 1; x += 6) {
    tft.drawLine(tft.width() - 1, 0, x, tft.height() - 1, color);
  }
  for (uint16_t y = 0; y < tft.height() - 1; y += 6) {
    tft.drawLine(tft.width() - 1, 0, 0, y, color);
  }

  tft.fillScreen(BLACK);
  for (uint16_t x = 0; x < tft.width() - 1; x += 6) {
    tft.drawLine(0, tft.height() - 1, x, 0, color);
  }
  for (uint16_t y = 0; y < tft.height() - 1; y += 6) {
    tft.drawLine(0, tft.height() - 1, tft.width() - 1, y, color);
  }

  tft.fillScreen(BLACK);
  for (uint16_t x = 0; x < tft.width() - 1; x += 6) {
    tft.drawLine(tft.width() - 1, tft.height() - 1, x, 0, color);
  }
  for (uint16_t y = 0; y < tft.height() - 1; y += 6) {
    tft.drawLine(tft.width() - 1, tft.height() - 1, 0, y, color);
  }

}

void testdrawtext(char *text, uint16_t color) {
  tft.setCursor(0, 0);
  tft.setTextColor(color);
  tft.print(text);
}

void testfastlines(uint16_t color1, uint16_t color2) {
  tft.fillScreen(BLACK);
  for (uint16_t y = 0; y < tft.height() - 1; y += 5) {
    tft.drawFastHLine(0, y, tft.width() - 1, color1);
  }
  for (uint16_t x = 0; x < tft.width() - 1; x += 5) {
    tft.drawFastVLine(x, 0, tft.height() - 1, color2);
  }
}

void testdrawrects(uint16_t color) {
  tft.fillScreen(BLACK);
  for (uint16_t x = 0; x < tft.height() - 1; x += 6) {
    tft.drawRect((tft.width() - 1) / 2 - x / 2, (tft.height() - 1) / 2 - x / 2 , x, x, color);
  }
}

void testfillrects(uint16_t color1, uint16_t color2) {
  tft.fillScreen(BLACK);
  for (uint16_t x = tft.height() - 1; x > 6; x -= 6) {
    tft.fillRect((tft.width() - 1) / 2 - x / 2, (tft.height() - 1) / 2 - x / 2 , x, x, color1);
    tft.drawRect((tft.width() - 1) / 2 - x / 2, (tft.height() - 1) / 2 - x / 2 , x, x, color2);
  }
}

void testfillcircles(uint8_t radius, uint16_t color)
{
  for (uint8_t x = radius; x < tft.width() - 1; x += radius2) {
    for (uint8_t y = radius; y < tft.height() - 1; y += radius2) {
      tft.fillCircle(x, y, radius, color);
    }
  }
}

void testdrawcircles(uint8_t radius, uint16_t color) {
  for (uint8_t x = 0; x < tft.width() - 1 + radius; x += radius2) {
    for (uint8_t y = 0; y < tft.height() - 1 + radius; y += radius2) {
      tft.drawCircle(x, y, radius, color);
    }
  }
}

void testtriangles() {
  tft.fillScreen(BLACK);
  int color = 0xF800;
  int t;
  int w = tft.width() / 2;
  int x = tft.height();
  int y = 0;
  int z = tft.width();
  for (t = 0 ; t <= 15; t += 1) {
    tft.drawTriangle(w, y, y, x, z, x, color);
    x -= 4;
    y += 4;
    z -= 4;
    color += 100;
  }
}

void testroundrects() {
  tft.fillScreen(BLACK);
  int color = 100;

  int x = 0;
  int y = 0;
  int w = tft.width();
  int h = tft.height();
  for (int i = 0 ; i <= 24; i++) {
    tft.drawRoundRect(x, y, w, h, 5, color);
    x += 2;
    y += 3;
    w -= 4;
    h -= 6;
    color += 1100;
    Serial.println(i);
  }

  void tftPrintTest();
  {
    tft.fillScreen(BLACK);
    tft.setCursor(0, 5);
    tft.setTextColor(RED);
    tft.setTextSize(1);
    tft.println("Hello World!");
    tft.setTextColor(YELLOW);
    tft.setTextSize(2);
    tft.println("Hello World!");
    tft.setTextColor(BLUE);
    tft.setTextSize(3);
    tft.print(1234.567);
    delay(1500);
    tft.setCursor(0, 5);
    tft.fillScreen(BLACK);
    tft.setTextColor(WHITE);
    tft.setTextSize(0);
    tft.println("Hello World!");
    tft.setTextSize(1);
    tft.setTextColor(GREEN);
    tft.print(p, 6);
    tft.println(" Want pi?");
    tft.println(" ");
    tft.print(8675309, HEX); // print 8,675,309 out in HEX!
    tft.println(" Print HEX!");
    tft.println(" ");
    tft.setTextColor(WHITE);
    tft.println("Sketch has been");
    tft.println("running for: ");
    tft.setTextColor(MAGENTA);
    tft.print(millis() / 1000);
    tft.setTextColor(WHITE);
    tft.print(" seconds.");
  }
  //
  /*!
    @brief Renders a simple test pattern on the screen
  */
  //
  void lcdTestPattern(void);
  {
    static const uint16_t PROGMEM colors =
    { RED, YELLOW, GREEN, CYAN, BLUE, MAGENTA, BLACK, WHITE };

    for (uint8_t c = 0; c < 8; c++) {
      tft.fillRect(0, tft.height() * c / 8, tft.width(), tft.height() / 8,
                   pgm_read_word(&colors[c]));

      void loop();
      {
        // set the brightness of pins:
        analogWrite(led04, brightness4);
        analogWrite(led05, brightness5);
        analogWrite(led06, brightness6);
        analogWrite(led07, brightness7);
        analogWrite(led2, brightness2);
        analogWrite(led3, brightness3);
        analogWrite(led10, brightness10);

        // change the brightness for next time through the loop:
        brightness4 = brightness4 + fadeAmount4;
        brightness5 = brightness5 + fadeAmount5;
        brightness6 = brightness6 + fadeAmount6;
        brightness7 = brightness7 + fadeAmount7;
        brightness2 = brightness2 + fadeAmount2;
        brightness3 = brightness3 + fadeAmount3;
        brightness10 = brightness10 + fadeAmount10;

      }

      // reverse the direction of the fading at the ends of the fade:
      if (brightness4 <= 0 || brightness4 >= 250) {
        fadeAmount4 = -fadeAmount4;
      }
      // reverse the direction of the fading at the ends of the fade:
      if (brightness4 <= 0 || brightness4 >= 250) {
        fadeAmount4 = -fadeAmount4;
      }
      // wait for 30 milliseconds to see the dimming effect
      delay(30);
    }
    //Blinking white LED randomizer
    digitalWrite(led3, !digitalRead(led3)); // turn the LED on/off
    randNumber = random(15, 25);

    //wait for randomizer

    delay(random(20, 20));

  }
}

What model Arduino are you using?

Tom... :smiley: :+1: :coffee: :australia:

this highlights various obvious problems ......may or maybe not all !!

`// Screen dimensions
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 128 // Change this to 96 for 1.27" OLED.
// You can use any (4 or) 5 pins
#define SCLK_PIN 37
#define MOSI_PIN 39
#define DC_PIN 35
#define CS_PIN 31
#define RST_PIN 33

// Color definitions
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1351.h>
#include <SPI.h>
#include <Arduino.h>

// Option 1: use any pins but a little slower
Adafruit_SSD1351 tft = Adafruit_SSD1351(SCREEN_WIDTH, SCREEN_HEIGHT, CS_PIN, DC_PIN, MOSI_PIN, SCLK_PIN, RST_PIN);

// Option 2: must use the hardware SPI pins
// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be
// an output. This is much faster - also required if you want
// to use the microSD card (see the image drawing example)
//Adafruit_SSD1351 tft = Adafruit_SSD1351(SCREEN_WIDTH, SCREEN_HEIGHT, &SPI, CS_PIN, DC_PIN, RST_PIN);

float p = 3.1415926;

int led04 = 4;        // the PWM pin the LED is attached to  ??????********** 04
int led05 = 5; // the PWM pin the LED is attached to??????**********05
int led06 = 6; // the PWM pin the LED is attached to??????**********06
int led07 = 7; // the PWM pin the LED is attached to??????**********07
int led2 = 2; // the PWM pin the LED is attached to
int led3 = 3; // the PWM pin the LED is attached to
int led10 = 10; // the PWM pin the LED is attached to
int brightness4 = 75; // how bright the c white LED is
int fadeAmount4 = 0; // how many points to fade the c white LED by
int brightness5 = 2; // how bright the yellow LED is
int fadeAmount5 = 6; // how many points to fade the yellow LED by
int brightness6 = 4; // how bright the red LED is
int fadeAmount6 = 2; // how many points to fade the red LED by
int brightness7 = 6; // how bright the green LED is
int fadeAmount7 = 3; // how many points to fade the green LED by
int brightness2 = 5; // how bright the blue LED is
int fadeAmount2 = 5; // how many points to fade the blue LED by
int brightness3 = 210; // how bright the b white LED is
int fadeAmount3 = 178; // how many points to fade the b white LED by
int brightness10 = 5; // how bright the red LED is
int fadeAmount10 = 17; // how many points to fade the red LED by
int randNumber;
int PrintTest;

// the setup routine runs once when you press reset:

void setup() {
  // declare pin 04 to be an output:
  pinMode(led04, OUTPUT);
  // declare pin 05 to be an output:
  pinMode(led05, OUTPUT);
  // declare pin 06 to be an output:
  pinMode(led06, OUTPUT);
  // declare pin 07 to be an output:
  pinMode(led07, OUTPUT);
  // declare pin 02 to be an output:
  pinMode(led2, OUTPUT);
  // declare pin 03 to be an output:
  pinMode(led3, OUTPUT);
  // declare pin 10 to be an output:
  pinMode(led10, OUTPUT);

                              // ??????**********  void setup(void);
  Serial.begin(9600);
  Serial.print("hello!");
  tft.begin();

  Serial.println("init");
  uint16_t time = millis();
  tft.fillRect(0, 0, 128, 128, BLACK);
  time = millis() - time;

  Serial.println(time, DEC);
  delay(500);

  tft.invert(true);
  delay(100);
  tft.invert(false);
  delay(100);

  //a single pixel
  tft.drawPixel(tft.width() / 2, tft.height() / 2, GREEN);
  delay(500);

  // line draw test
  testlines(YELLOW);
  delay(500);

  // optimized lines
  testfastlines(RED, BLUE);
  delay(500);

  testdrawrects(GREEN);
  delay(1000);

  testfillrects(YELLOW, MAGENTA);
  delay(1000);

  tft.fillScreen(BLACK);
  testfillcircles(10, BLUE);
  testdrawcircles(10, WHITE);
  delay(1000);

  testroundrects();
  delay(500);

  testtriangles();
  delay(500);

  Serial.print("done!");
  delay(500);
}
void testlines(uint16_t color) {
  tft.fillScreen(BLACK);
  for (uint16_t x = 0; x < tft.width() - 1; x += 6) {
    tft.drawLine(0, 0, x, tft.height() - 1, color);
  }
  for (uint16_t y = 0; y < tft.height() - 1; y += 6) {
    tft.drawLine(0, 0, tft.width() - 1, y, color);
  }

  tft.fillScreen(BLACK);
  for (uint16_t x = 0; x < tft.width() - 1; x += 6) {
    tft.drawLine(tft.width() - 1, 0, x, tft.height() - 1, color);
  }
  for (uint16_t y = 0; y < tft.height() - 1; y += 6) {
    tft.drawLine(tft.width() - 1, 0, 0, y, color);
  }

  tft.fillScreen(BLACK);
  for (uint16_t x = 0; x < tft.width() - 1; x += 6) {
    tft.drawLine(0, tft.height() - 1, x, 0, color);
  }
  for (uint16_t y = 0; y < tft.height() - 1; y += 6) {
    tft.drawLine(0, tft.height() - 1, tft.width() - 1, y, color);
  }

  tft.fillScreen(BLACK);
  for (uint16_t x = 0; x < tft.width() - 1; x += 6) {
    tft.drawLine(tft.width() - 1, tft.height() - 1, x, 0, color);
  }
  for (uint16_t y = 0; y < tft.height() - 1; y += 6) {
    tft.drawLine(tft.width() - 1, tft.height() - 1, 0, y, color);
  }

}

void testdrawtext(char *text, uint16_t color) {
  tft.setCursor(0, 0);
  tft.setTextColor(color);
  tft.print(text);
}

void testfastlines(uint16_t color1, uint16_t color2) {
  tft.fillScreen(BLACK);
  for (uint16_t y = 0; y < tft.height() - 1; y += 5) {
    tft.drawFastHLine(0, y, tft.width() - 1, color1);
  }
  for (uint16_t x = 0; x < tft.width() - 1; x += 5) {
    tft.drawFastVLine(x, 0, tft.height() - 1, color2);
  }
}

void testdrawrects(uint16_t color) {
  tft.fillScreen(BLACK);
  for (uint16_t x = 0; x < tft.height() - 1; x += 6) {
    tft.drawRect((tft.width() - 1) / 2 - x / 2, (tft.height() - 1) / 2 - x / 2 , x, x, color);
  }
}

void testfillrects(uint16_t color1, uint16_t color2) {
  tft.fillScreen(BLACK);
  for (uint16_t x = tft.height() - 1; x > 6; x -= 6) {
    tft.fillRect((tft.width() - 1) / 2 - x / 2, (tft.height() - 1) / 2 - x / 2 , x, x, color1);
    tft.drawRect((tft.width() - 1) / 2 - x / 2, (tft.height() - 1) / 2 - x / 2 , x, x, color2);
  }
}

void testfillcircles(uint8_t radius, uint16_t color)
{
  for (uint8_t x = radius; x < tft.width() - 1; x += radius2) {
    for (uint8_t y = radius; y < tft.height() - 1; y += radius2) {
      tft.fillCircle(x, y, radius, color);
    }
  }
}

void testdrawcircles(uint8_t radius, uint16_t color) {
  for (uint8_t x = 0; x < tft.width() - 1 + radius; x += radius2) {
    for (uint8_t y = 0; y < tft.height() - 1 + radius; y += radius2) {
      tft.drawCircle(x, y, radius, color);
    }
  }
}

void testtriangles() {
  tft.fillScreen(BLACK);
  int color = 0xF800;
  int t;
  int w = tft.width() / 2;
  int x = tft.height();
  int y = 0;
  int z = tft.width();
  for (t = 0 ; t <= 15; t += 1) {
    tft.drawTriangle(w, y, y, x, z, x, color);
    x -= 4;
    y += 4;
    z -= 4;
    color += 100;
  }
}

void testroundrects() {
  tft.fillScreen(BLACK);
  int color = 100;

  int x = 0;
  int y = 0;
  int w = tft.width();
  int h = tft.height();
  for (int i = 0 ; i <= 24; i++) {
    tft.drawRoundRect(x, y, w, h, 5, color);
    x += 2;
    y += 3;
    w -= 4;
    h -= 6;
    color += 1100;
    Serial.println(i);
  }

  void tftPrintTest()          //; ??????**********
  {
    tft.fillScreen(BLACK);
    tft.setCursor(0, 5);
    tft.setTextColor(RED);
    tft.setTextSize(1);
    tft.println("Hello World!");
    tft.setTextColor(YELLOW);
    tft.setTextSize(2);
    tft.println("Hello World!");
    tft.setTextColor(BLUE);
    tft.setTextSize(3);
    tft.print(1234.567);
    delay(1500);
    tft.setCursor(0, 5);
    tft.fillScreen(BLACK);
    tft.setTextColor(WHITE);
    tft.setTextSize(0);
    tft.println("Hello World!");
    tft.setTextSize(1);
    tft.setTextColor(GREEN);
    tft.print(p, 6);
    tft.println(" Want pi?");
    tft.println(" ");
    tft.print(8675309, HEX); // print 8,675,309 out in HEX!
    tft.println(" Print HEX!");
    tft.println(" ");
    tft.setTextColor(WHITE);
    tft.println("Sketch has been");
    tft.println("running for: ");
    tft.setTextColor(MAGENTA);
    tft.print(millis() / 1000);
    tft.setTextColor(WHITE);
    tft.print(" seconds.");
  }
  //
  /*!
    @brief Renders a simple test pattern on the screen
  */
  //
  void lcdTestPattern(void)        //; ??????**********
  {
    static const uint16_t PROGMEM colors =
    { RED, YELLOW, GREEN, CYAN, BLUE, MAGENTA, BLACK, WHITE };

    for (uint8_t c = 0; c < 8; c++) {
      tft.fillRect(0, tft.height() * c / 8, tft.width(), tft.height() / 8,
                   pgm_read_word(&colors[c]));

      void loop()   //;   ??????**********
      {
        // set the brightness of pins:
        analogWrite(led04, brightness4);
        analogWrite(led05, brightness5);
        analogWrite(led06, brightness6);
        analogWrite(led07, brightness7);
        analogWrite(led2, brightness2);
        analogWrite(led3, brightness3);
        analogWrite(led10, brightness10);

        // change the brightness for next time through the loop:
        brightness4 = brightness4 + fadeAmount4;
        brightness5 = brightness5 + fadeAmount5;
        brightness6 = brightness6 + fadeAmount6;
        brightness7 = brightness7 + fadeAmount7;
        brightness2 = brightness2 + fadeAmount2;
        brightness3 = brightness3 + fadeAmount3;
        brightness10 = brightness10 + fadeAmount10;

      }

      // reverse the direction of the fading at the ends of the fade:
      if (brightness4 <= 0 || brightness4 >= 250) {
        fadeAmount4 = -fadeAmount4;
      }
      // reverse the direction of the fading at the ends of the fade:
      if (brightness4 <= 0 || brightness4 >= 250) {
        fadeAmount4 = -fadeAmount4;
      }
      // wait for 30 milliseconds to see the dimming effect
      delay(30);
    }
    //Blinking white LED randomizer
    digitalWrite(led3, !digitalRead(led3)); // turn the LED on/off
    randNumber = random(15, 25);

    //wait for randomizer

    delay(random(20, 20));

  }
}

I am doing this on a MEGA. i plan on trying to shrink the package down to a NANO for space saving issues. I think i broke the 2 OLED screens i had and am now using one of those yellow and blue OLED screens. ill go back and check my other screen soon. Came down with covid so i havent been doing much. I have it working so far with the other screen. One issue im having is i have a obstacle sensor that i am using to sense when something is there and turn OFF everything. I can get it to turn off the LEDs but the screen stays on. i need it off. Any assistance.
Also i dont know but it seems like my autoformat doesnt do anything,

any help would be great