How to corectly write the code ?





I am just a bigginer and I have the classic arduino uno starting pack and I have just discovered my first problem about the coding.
I have puted the code exactly from the book to the app, but it just shows some errors.

Every one is a beginner at some point. But to really begin,please read this forum post and then try to submit your information as requested.

In addition, do not show what is written in a book or pictures of the setup in a book, etc. Show the code you have, because that is where a problem may lie. Same with your wiring and other components, Show what you have, not what someone else has done.

1 Like

You seem to have some misplaced braces in the code. Selecting Tools/Auto Format from the menu at the top of the IDE may help to show you where things went wrong.

There are two errors. I will help you with the first, and you can solve the second. In the loop function, remove the brace, as shown in the comment below.

    switchState = digitalRead(2);
}  // remove this brace
1 Like

You were right now it works just like it is expected to work in the book. Thank you so much.

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