Expected ')' before ';' token at #define

I Hello! I have a question. I want to do a code about a 7 segment 1 digit display but I have a problem with my #define's


// the setup function runs once when you press reset or power the board
void setup() {
#define g 13;
#define f 12;
#define a 11;
#define b 10;
#define e 9;
#define d 8;
#define c 7;
#define dp 6;
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(g, HIGH);
  digitalWrite(f, HIGH);
  digitalWrite(e, HIGH);
  digitalWrite(a, HIGH);
  digitalWrite(d, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
  delay(500);
  digitalWrite(f, LOW);
  digitalWrite(e, LOW);
  digitalWrite(a, LOW);
  digitalWrite(d, LOW);
  delay(500);
  digitalWrite(g, LOW);
  digitalWrite(f, HIGH);
  digitalWrite(e, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
  delay(500);
  digitalWrite(d, HIGH);
  digitalWrite(a, HIGH);
  digitalWrite(g, HIGH);
  delay(500);
  digitalWrite(a, LOW);
  digitalWrite(d, LOW);
  digitalWrite(g, LOW);
  digitalWrite(f, LOW);
  digitalWrite(e, LOW);
  delay(500);
  digitalWrite(f, LOW);
  digitalWrite(e, LOW);
  digitalWrite(d, LOW);
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
  delay(500);
  digitalWrite(f, HIGH);
  digitalWrite(e, HIGH);
  digitalWrite(d, HIGH);
  delay(500);
  digitalWrite(f, LOW);
  digitalWrite(e, LOW);
  digitalWrite(d, LOW);
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
  delay(500);
  digitalWrite(f, HIGH);
  digitalWrite(e, HIGH);
  digitalWrite(a, HIGH);
  digitalWrite(d, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
  delay(500);
  digitalWrite(f, LOW);
  digitalWrite(e, LOW);
  digitalWrite(a, LOW);
  digitalWrite(d, LOW);
  delay (2000);
}

It keeps saying that I need to put some () to my #define's

Don't put defines in setup().

The define does not end with ;

You will need to set those pins to pinMode OUTPUT.

Your code with some corrections:

// the setup function runs once when you press reset or power the board
#define g 13
#define f 12
#define a 11
#define b 10
#define e 9
#define d 8
#define c 7
#define dp 6

void setup()
{
   pinMode(g, OUTPUT);
   pinMode(f, OUTPUT);
   pinMode(a, OUTPUT);
   pinMode(b, OUTPUT);
   pinMode(c, OUTPUT);
   pinMode(d, OUTPUT);
   pinMode(e, OUTPUT);
   pinMode(dp, OUTPUT);
}

// the loop function runs over and over again forever
void loop()
{
   digitalWrite(g, HIGH);
   digitalWrite(f, HIGH);
   digitalWrite(e, HIGH);
   digitalWrite(a, HIGH);
   digitalWrite(d, HIGH);
   digitalWrite(b, HIGH);
   digitalWrite(c, HIGH);
   delay(500);
   digitalWrite(f, LOW);
   digitalWrite(e, LOW);
   digitalWrite(a, LOW);
   digitalWrite(d, LOW);
   delay(500);
   digitalWrite(g, LOW);
   digitalWrite(f, HIGH);
   digitalWrite(e, HIGH);
   digitalWrite(b, HIGH);
   digitalWrite(c, HIGH);
   delay(500);
   digitalWrite(d, HIGH);
   digitalWrite(a, HIGH);
   digitalWrite(g, HIGH);
   delay(500);
   digitalWrite(a, LOW);
   digitalWrite(d, LOW);
   digitalWrite(g, LOW);
   digitalWrite(f, LOW);
   digitalWrite(e, LOW);
   delay(500);
   digitalWrite(f, LOW);
   digitalWrite(e, LOW);
   digitalWrite(d, LOW);
   digitalWrite(b, HIGH);
   digitalWrite(c, HIGH);
   delay(500);
   digitalWrite(f, HIGH);
   digitalWrite(e, HIGH);
   digitalWrite(d, HIGH);
   delay(500);
   digitalWrite(f, LOW);
   digitalWrite(e, LOW);
   digitalWrite(d, LOW);
   digitalWrite(b, HIGH);
   digitalWrite(c, HIGH);
   delay(500);
   digitalWrite(f, HIGH);
   digitalWrite(e, HIGH);
   digitalWrite(a, HIGH);
   digitalWrite(d, HIGH);
   digitalWrite(b, HIGH);
   digitalWrite(c, HIGH);
   delay(500);
   digitalWrite(f, LOW);
   digitalWrite(e, LOW);
   digitalWrite(a, LOW);
   digitalWrite(d, LOW);
   delay (2000);
}

Thanks. Now it works!

What should the display show ? I can't read it: https://wokwi.com/projects/338898927533163091 [EDIT] The Wokwi server is down, 1 hour after this post

if you want less problems, don't use single-letter names for defines, so as not to confuse them with variables.
Defines are usually denoted only in capital letters, connected with underscores, and called understandable names, for example, UART_RX_BUFFER_LENGTH or MY_FIRST_ARDUINO_DEFINE :slight_smile:

The language reference is here for you to search and get your syntax right. It is only a 2 second Google away

I would recommend not to use #define at all as it can lead to all sorts of problems. Maybe consider the following instead:

byte const pin_g 7;
// etc.

Why does it lead to problems. It is very useful to make your code readable. Not in this case obviously as it is being used to make the code less readable

At the end of this page there are a number of very nice examples.

https://stroustrup.com/bs_faq2.html

As for readability, this can usually be accomplished by declaring a variable, writing an (inline) function or by other (type safe) means.

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