Arduino functions

Calculon is discovering the wonders of arduino programming, and he is confused with the function (subroutine) action. He defines and declares a function, but nothing happens. Behold the simplified code:

void loop(){

goMotor; //call the goMotor function


void goMotor(){ //activate dc motor via h-bridge



When Calculon runs the above code, nothing happens. If he types the digitalWrite commands within the LOOP, it works fine. ditto for serial.print and anyother digitalWrite commands. Calculon demands answers.

Don't C functions have the same use as a BASIC subroutine? Or do they only work to return a mathematical value?

Calculon OUT


You need parenthesis when you call the function:


I’m surprised that this compiled actually?! :confused:

that was fast. gracias

The paranthesis are required

The paranthesis are required because you can pass values to functions for example if you wanted a simple function to add numbers:

void main()

int x;
x = add_integers(1, 2);

int add_integers(int number_one, int number_two)


X equals whatever is returned by the function. Since you passed it the values 1 and 2 those numbers are added and sent back to main via return();. Of course you would never create an add function since it is built in, but you get the point. You can also pass by reference, value or by pointer, but that’s a bit more advanced.

The parathensis are REQUIRED even if you don’t pass anything so it knows you mean to call a function and not a variable.
domath and domath() are 2 different things.