void setup()
{
pinMode{13, OUTPUT};
}
void loop() {
digitalWrite{13, HIGH};
}
Try parentheses instead of curly braces:
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
}
-
1It's funny and nonsense, but
pinMode; { ...
is formally correct. That makes error messages hard to understand. – DataFiddler May 23 '19 at 7:30
The solution is already give, but here an explanation:
{
and }
are used to group multiple statements together, either for a function, if, while, for loop and so on.
E.g.
if (i == 1)
{
// Statement 1
// Statement 2
}
or a function
void f()
{
// Statement 1
// Statement 2
}
(
and )
are used to specify parameters:
void f(int a, int b)
{
...
}
A function with two parameters.
When calling this function, the following is used:
f(1, 2);
Calls function f
with a = 1
, and b = 2
.
So in general: {
and }
is for grouping statements, (
and )
for parameters.
-
{}
is also used in initializer syntax, which might lead to other confusing error messages for incorrect code. – AnT May 23 '19 at 22:29 -
@AnT True, I didn't make a complete list to make my answer not overly difficult for beginners. {} is also used for begin/end of a class as other example. – Michel Keijzers May 23 '19 at 22:34
I made same mistake when I started working with C
you have
pinMode{13, OUTPUT};
which should be
pinMode(13, OUTPUT);
the curly brackets are basically for Start and End of a function.
Bill
digitalWrite(13,HIGH);
rather than curly brackets, and do the same forpinMode
– MichaelT May 23 '19 at 7:31{}
brackets after function name? – AnT May 23 '19 at 7:57