26
Mark major sections or functions with a comment header line or two
Have just the right number of comments, not too few and not too many. Assume the reader
knows the programming language so have the comment be instructive. Here is an example of
an instructive comment
digitalWrite(4,HIGH) // turn on motor
and here is a useless comment
digitalWrite(4,HIGH) // set pin 4 HIGH
You need not comment every line. In fact, commenting every line is generally bad practice.
Add the comments when you create the code. If you tell yourself, "Oh, I'll add the comments
when the code is finished", you will never do it.
10 Common Coding Errors
Forgetting the semi-colon at the end of a statement
Misspelling a command
Omitting opening or closing braces
Please send comments, suggestions and typo alerts about this guide to wkdurfee@umn.edu
11 Appendix
On the following page is a summary of basic Arduino commands, with examples.