Creating my own function

I have looked in reference on the main site and have not found a tutorial on creating my own function.

For example if I wanted to call "Fastblink()" and have leds create a specific pattern, I would need to make the function called Fastblink.

Could someone point me to a page showing me how to set-up/make a function?


To create a function, you need to define a name, any input arguments and their types, and a return type.

Suppose fastBlink needs to know what pin to blink, how many times to blink the pin, and how long to wait between blinks. There is nothing that the function does that the caller needs to know about. The return type is then void:

void fastBlink(int pinNumber, int blinkCount, unsigned long blinkTime)
  // Write your code here

Each variable has a type, and a meaningful (to me, at least) name. Given this skeleton, actually writing the code should be quite easy.

Creating a function for the Arduino is no different from writing a function in C for any other computer, which is why the Arduino documentation barely mentions it.

Thank you Paul S for the clear explanation!