digitalWrite() problem:/

So i am using digitalWrite and for some reason it says that the comma(,) is the bug? i really have no idea what to even look for:))

X_O.ino (8.14 KB)

ursulafiig11:
So i am using digitalWrite and for some reason it says that the comma(,) is the bug? i really have no idea what to even look for:))

Hint: we can't see your code, and have no idea what your error message is.

??

How will anyone looking at thread topics know what you are asking about? You'll get a lot more responses if you use a subject line that is your question boiled down, and include your code. And use the code tags so it formats.

Otherwise, how are we supposed to know what comma that is?

That was dumb. fairly new still:) but ive simply written digitalWrite(cirkel1, HIGH); and it says that thereis an expected primary expression before

ive put my code on there if you would want to help me:) i am very greatful if you will:)

In your code you are defining a huge set of macros that are just empty

#define cirkel1
#define cirkel2
#define cirkel3
...

When you use these macros in the code they get replaced with nothing. So your

digitalWrite(cirkel1, HIGH);

becomes just

digitalWrite(, HIGH);

This is invalid and this is what the compiler is telling you.

Why are you declaring all these macros as empty? Apparently you intended to use them as pin numbers, but you forgot to specify the actual numbers.

If you can't recognize such basic errors, then a good idea would be to browse through some C, C++ and Arduino tutorials first.

This is a good example of why it's a bad idea to use #define for this purpose. There is no benefit to it and it makes your code harder to debug. This is the better way to do it:

const byte button1 = 6;
const byte button2 = 3;
const byte button3 = 8;
const byte button4 = 10;
const byte button5 = 13;
const byte button6 = 5;
const byte button7 = 7;
const byte button8 = 9;
const byte button9 = 2;

Of course, you would need to adjust that to the actual pin number of your project. I just threw some random numbers in there for the purposes of the demonstration.

As a beginner, the only place you should use preprocessor directives in your code (preprocessor directives start with #) is #include. Once you become an advanced user you can take advantage of the capabilities of the preprocessor, but even then you should only use it when absolutely necessary.

More information:
https://www.arduino.cc/reference/en/language/structure/further-syntax/define/

In general, the const keyword is preferred for defining constants and should be used instead of #define.

Thank you! i didnt even think i could forget that/:))

boolrules:
And using limited storage just to hold a value

There is no difference. The compiler engineers are smart people.

boolrules:
used once during setup( )

Used once? Which of those is only used once?

pert:
This is a good example of why it’s a bad idea to use #define for this purpose.

Well no, incorrect use of a feature is simply wrong and needs fixing. You can worry
about subtle and contestable issues of style after fixing basic errors.

The C-preprocessor directives are something you simply need to know, so learn there
basic use rather than avoid them.

MarkT:
The C-preprocessor directives are something you simply need to know, so learn there
basic use rather than avoid them.

I disagree. Most Arduino users can do anything they want to accomplish without using any preprocessor directive other than #include in their code. You can't learn everything at one time. A beginner must start by learning the most important things first. Preprocessor directives come far, far down the list of what's important for someone at the learning stage where ursulafiig11 is at. All they need to know for now is: don't use them! As I already said, later down the line when they want to get into more advanced stuff, they can dive into the preprocessor.