arduino Functions Call a function


Example

If you have a function declared you can call it anywhere else in the code. Here is an example of calling a function:

void setup(){
  Serial.begin(9600);
}

void loop() {
  int i = 2;

  int k = squareNum(i); // k now contains 4
  Serial.println(k);
  delay(500);
}

int squareNum(int a) {
    return a*a;
}