What is functions? Why do we need to use them? Now I will explain it to you!
OK, let's with little introduction. I have found website with very good explanation, if you want to learn more about them, it will be good idea to visit it.
We need to use functions to make our program easyer and more complicated.
Syntax of functions:
type_of_function name_of_function(variables(input) if needed)
{
//do staff
return value; //if needed
}
And now, how to call(execute it):
Form another function.
void loop()
{
name_of_function(variables(input) if needed);
}
Now I will show you a little example:
void setup()
{
digitalPin(13, OUTPUT);
}
void bLED()
{
digitalWrite(13, HIGH);
delay(200);
digitalWrite(13, LOW);
}
void loop()
{
bLED();
}
If you have got some questions, fell free to ask me.
No comments:
Post a Comment