O'Reilly logo

Getting Started with Arduino by Massimo Banzi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix C. Arduino Quick Reference

Here is a quick explanation of all the standard instructions supported by the Arduino language.

For a more detailed reference, see: arduino.cc/en/Reference/HomePage

STRUCTURE

An Arduino sketch runs in two parts:

void setup()

This is where you place the initialisation code—the instructions that set up the board before the main loop of the sketch starts.

void loop()

This contains the main code of your sketch. It contains a set of instructions that get repeated over and over until the board is switched off.

SPECIAL SYMBOLS

Arduino includes a number of symbols to delineate lines of code, comments, and blocks of code.

; (semicolon)

Every instruction (line of code) is terminated by a semicolon. This syntax lets you format the code freely. You could even put two instructions on the same line, as long as you separate them with a semicolon. (However, this would make the code harder to read.)

Example:

delay(100);

{} (curly braces)

This is used to mark blocks of code. For example, when you write code for the loop() function, you have to use curly braces before and after the code.

Example:

void loop() {
   Serial.println("ciao");
}

comments

These are portions of text ignored by the Arduino processor, but are extremely useful to remind yourself (or others) of what a piece of code does.

There are two styles of comments in Arduino:

// single-line: this text is ignored until the end of the line
/* multiple-line:
   you can write
   a whole poem in here
*/

CONSTANTS

Arduino includes a set of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required