I have been programming as long as I can remember, everything from teletypes and mainframes to personal computers and embedded devices. I have programmed games, business applications, websites and mobile apps but I can honestly say that I enjoy programming microcontroller boards like the Arduino the most.
The reason for this is with microcontrollers my programs can interact with the outside world through various sensors and motors rather than programming for simple human interaction. With microcontrollers we are only limited by our imagination and ingenuity however before we can begin conquering the world, we must first learn the basics of the Arduino programming language.
In this chapter, you will learn:
- What variables and constants are and how to use them
- What math functions the Arduino programming language offer
- How to add comments to our...
Comments
There are two types of comments that can be used to within our Arduino code. These are block comments and line comments. Block comments are used when the text of the comment will span multiple lines and are usually used before function calls to let the reader know what a function does. The line comments are used when a short one-line comment is needed and are usually used within function blocks to let the reader know what a specific line of code is doing.
A block comment begins with /* and ends with */. The following code shows what a block comment would look like:
A line comment starts with // and goes until the end of the line. The line comment can start at the beginning of the line or it may be after a statement ends. The following examples...