Introduction

Consider the following sketch:

void setup () {

     Serial.begin(9600);

     printHeader();

}

void loop () }{

     calculateTime();

     readData();

     printData();

}

Hopefully you find its streamlined code structure to be easy to read and understand. You can work towards creating code like this with the use of functions. 

Objectives

  • Learn formatting for creating and calling a function
  • Distinguish between local and global variables
  • Explore how functions can streamline your code, making it easier to understand and more efficient