Error message while copying code

HI Folks, i was trying to verify this code which I am actually copying and learning at the same time, however it will not verify and keeps on saying that a ":" is missing.
Any advice would be much appreciated. Thanks

The first 4 lines are good and then the error code:

Users\chris\OneDrive\Documents\Arduino\blink_example\blink_example.ino: In function 'void setup()':

blink_example:8:8: error: expected ';' before '{' token

pinMode{myled1, OUTPUT}; //assign pin 4 as output

    ^

blink_example:9:8: error: expected ';' before '{' token

pinMode{myled2, OUTPUT}; //assign pin 5 as output

    ^

C:\Users\chris\OneDrive\Documents\Arduino\blink_example\blink_example.ino: In function 'void loop()':

blink_example:14:13: error: expected ';' before '{' token

digitalWrite{myled1, HIGH};

         ^

exit status 1

expected ';' before '{' token

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

`int myled1 = 4;       //declare myled1 as the first led`
`int myled2 = 5;       //declare myled2 as the second led`
`int onTime1 = 1000;   //declare ontime as 1 second`
`int offTime = 1500;   //declare offtime as 1.5 seconds`



void setup() {
pinMode{myled1, OUTPUT}; //assign pin 4 as output
pinMode{myled2, OUTPUT}; //assign pin 5 as output

}

`void loop() {`

`digitalWrite{myled1, HIGH};`

How are you copying it, and from where?

If you look up the documentation for pinMode, you will not see a "{" mentioned anywhere. :slight_smile:

Oh, wait, I see... you are just reading and typing to copy... and not paying attention... Okay...

Function calls such as the offending pinmode take round brackets, not braces. ( not {.

1 Like

You can not learn much without reading the documentation and following some tutorials or examples. Guessing won't get you there.

Thanks folks. Yes I could also just copy and paste the code, but need to learn and start somewhere.

thanks for pointing it out - now I have learnt something new.
Cheers

Many thanks

Hi,
Welcome to the forum.

Does your code now compile?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

1 Like

yes it does - thanks Tom

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