Learning Arduino code basics

Here we begin with the basics of coding for Arduino. Writing code for Arduino and other embedded platforms is a little different from writing code for a computer. But don't fear—the differences are small.

Getting ready

To execute this recipe, we need just one ingredient: the Arduino IDE running on a computer.

How to do it…

These are the two mandatory functions in the Arduino coding environment:

void setup() {
  // Only execute once when the Arduino boots
}


void loop(){
  // Code executes top-down and repeats continuously
}

How it works…

Each Arduino sketch has two mandatory functions: the setup() function and the loop() function. The setup() function only executes once: either when we apply power to the Arduino or when it resets. ...

Get Arduino Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.