My code is not working, pls help

Hello, I'm a beginner and trying to to write some code to make an led flash and it gives my this error, here is my code.

error is "Compilation error: expected ')' before '=' token"


const int(RED, 13);
void setup() {
  // put your setup code here, to run once:
pinMode(RED, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
digitalWrite(RED, HIGH);
delay(300);
digitalWrite(RED, LOW);
delay(300);
}

That's not correct syntax. Try:

const int RED = 13;
2 Likes

The compiler will tell you what line it found that error on. Inspect that line for problems.

2 Likes

I have gotten pages of errors for a missing semicolon. When that happens go to the top of the error list and start there, it is usually in the first line that shows your program line number.

1 Like

You can post the errors in code tags too. I got these when I tried compiling your code:

sketch.ino:1:14: error: expected ')' before ',' token
 const int(RED, 13);
              ^
sketch.ino:1:16: error: expected unqualified-id before numeric constant
 const int(RED, 13);
                ^~
sketch.ino: In function 'void setup()':
sketch.ino:4:9: error: 'RED' was not declared in this scope
 pinMode(RED, OUTPUT);
         ^~~
sketch.ino: In function 'void loop()':
sketch.ino:9:14: error: 'RED' was not declared in this scope
 digitalWrite(RED, HIGH);
              ^~~

Error during build: exit status 1

They indicate bad syntax on that first line.

It should look more like the examples from https://docs.arduino.cc/language-reference/en/variables/data-types/int/ :

1 Like

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