void functions

can someone please explain to me how use void functions like:

void moveball()

work?

it seems that they work in a manner similar to variables or maybe libraries, but I don't understand how and when to use them

Say you had the code:

unsigned long previousMillis;
long interval = 4000;

void setup(){}

void loop()
{
previousMillis = millis();
if(millis() - previousMillis < interval) {
}
}

You could condense this into a function [void because it doesn’t return a data type].

unsigned long previousMillis;

void setup(){
}

void loop()
{
pause(1000);
}

void pause(long interval) {
previousMillis = millis();
if(millis() - previousMillis < interval) {
}
}

See here: http://www.arduino.cc/en/Reference/FunctionDeclaration

/me

Any time you have a short sequence of steps in your sketch that appears more than once, you can make those steps into a void function and then call the function in their place. It's a bit like a sub-sketch, something that does a small snippet of code that's useful in various places. The advantage is that using a void function will take up less code memory space than writing out the program steps each time you need them.

Non-void functions can be used to compute a value (say, an integer) and return it to the main part of the sketch. Functions like 'analogRead()' do that.

Functions can take parameters, just like 'digitalWrite()' does, that specify which pin to use, or to pass an integer value in.

cool thanks, that helps