Friday 28 April 2017

Functions - Arduino

 As your programs become more complicated we try to break up the code into
more easily managed blocks.
We break them up into "functions".
 
The arduino main reference page lists all the major functions:

The two essential functions in any sketch are
void setup (){}
and 
void loop (){}

 All functions must have these basic things:
1. unique name [alphanumeric characters (A to Z; a to z; 0 to 9) and the underscore (_).]
    You can't start the name with a number.
2. the name must be followed by ()
3. they must have a return type : eg void
4. The body of the function is enclosed in braces {}
 
-------------------------------------------------------------------------

Structure of functions.

This is an example of a function that was created to print the numbers 123456789. 
In this example the name "NumbersAcend()" is the function name.
In this example "void" is referred to as the return type

void NumbersAcend()
{
      Serial.println("123456789");
 }
 
 
 Links
+ https://www.youtube.com/watch?v=VHK69SB3lo4
 
 
 ---------------------------------
-------------------------------------

No comments:

Post a Comment