Error tells me part of arduinos own code is wrong

Error below says that there is a missing semicolon in arduinos own code, and it has never thrown this error before.

In file included from C:\Users\20stu\AppData\Local\Temp\arduino\sketches\5C8C421AFF7F1C319E5D38FE89B21BE0\sketch\MarksmanFill.ino.cpp:1:0:
C:\Users\20stu\OneDrive\Documents\Arduino\MarksmanFill\MarksmanFill.ino: In function 'void setup()':
C:\Users\20stu\AppData\Local\Arduino15\packages\arduino\hardware\renesas_uno\1.2.0\cores\arduino/Arduino.h:113:16: error: expected ';' before '_UART1_'
 #define Serial _UART1_
                ^
C:\Users\20stu\OneDrive\Documents\Arduino\MarksmanFill\MarksmanFill.ino:23:5: note: in expansion of macro 'Serial'
     Serial.begin(115200);
     ^~~~~~

exit status 1

Compilation error: exit status 1

My code is attached below

#include <TFT_eSPI.h>

TFT_eSPI tft = TFT_eSPI();

const int buttonPin = 2;

int charges = 4;
int chargeprogress = 0;

int startx = 40;
int starty = 39;
int offsetx = 34;
int offsety = 34;

#include "dot.h"
#include "dotoutline.h"
; // it wont let me run the code without an error stating it needs a semicolon here, no idea why
void setup() {
  pinMode(buttonPin, INPUT);

  attachInterrupt(digitalPinToInterrupt(2), chargedecline, RISING)

    Serial.begin(115200);

  tft.begin();

  // Swap the colour byte order when rendering
  tft.setSwapBytes(true);
  tft.setRotation(2);

  tft.fillScreen(TFT_BLACK);

  tft.pushImage(34, 34, dotWidth, dotHeight, dot);
  tft.pushImage(34, 128, dotWidth, dotHeight, dot);
  tft.pushImage(128, 34, dotWidth, dotHeight, dot);
  tft.pushImage(128, 128, dotWidth, dotHeight, dot);
}

void chargedecline() {
  if (charges >= 0) {
    charges -= 1;
  }
  if (chargeprogress > 0) {
    tft.fillRect(offsetx, offsety, 80, 80, TFT_BLACK);
  }
  if (charges > 2) {
    offsetx = 34;
    offsety = 34;
  } else if (charges == 2) {
    offsetx = 128;
    offsety = 334;
  } else if (charges == 1) {
    offsetx = 34;
    offsety = 128;
  } else {
    offsetx = 128;
    offsety = 128;
  }
}

void loop() {
  // put your main code here, to run repeatedly:
  if (charges < 4) {
    tft.fillRect(offsetx, offsety, 80, 80, TFT_BLACK);
    for (int i = 0; i < 79; i++) {
      tft.drawLine(startx + offsetx, starty + offsety, dotoutline[i][0] + offsetx, dotoutline[i][1] + offsety, TFT_BLUE);
      if (i == chargeprogress) {
        chargeprogress += 1;
        delay(12);
      }
    }
    startx = 40;
    starty = 40;
    for (int i = 0; i < 79; i++) {
      tft.drawLine(startx + offsetx, starty + offsety, dotoutline2[i][0] + offsetx, dotoutline2[i][1] + offsety, TFT_BLUE);
      if (i + 79 == chargeprogress) {
        chargeprogress += 1;
        delay(12);
      }
    }
    startx = 39;
    starty = 40;
    for (int i = 0; i < 79; i++) {
      tft.drawLine(startx + offsetx, starty + offsety, dotoutline3[i][0] + offsetx, dotoutline3[i][1] + offsety, TFT_BLUE);
      if (i + 158 == chargeprogress) {
        chargeprogress += 1;
        delay(12);
      }
    }
    startx = 39;
    starty = 39;
    for (int i = 0; i < 79; i++) {
      tft.drawLine(startx + offsetx, starty + offsety, dotoutline4[i][0] + offsetx, dotoutline4[i][1] + offsety, TFT_BLUE);
      if (i + 237 == chargeprogress) {
        chargeprogress += 1;
        delay(12);
      }
    }
    startx = 40;
    starty = 39;
    tft.pushImage(offsetx, offsety, dotWidth, dotHeight, dot);
  }
}

Which Arduino board have you got selected in the IDE ?

You forgot the ; at the end of this line

The UNO R4 WiFi

Thanks, I don't get why it threw that error but thats what was wrong.

C++ requires a semi colon at the end of that statement.... so that's what the compiler tells you but it gets the line of code wrong because of apparently a macro

what type of Arduino are you using for Serial to be a macro ?..

The next line in your code is

, aka the UART. It's telling you the error is just before this line, which is how I found it.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.