Return

From Microduino Wiki
Jump to: navigation, search
  • return

To terminate a function, and if there is a return value, it will be returned to the calling function through this function.

  • Syntax:

return;
return value; // the two forms are both ok
  • Parameters

value:the type of any variable and constant

  • Example:

A function to compare the threshold of the sensor input


 int checkSensor(){       
    if (analogRead(0) > 400) {
        return 1;}
    else{
        return 0;
    }
}

Keyword return can easily test a piece of code, without “commenting out” great block of possible bug code.


void loop(){
 
//write beautiful code to test here. 
 
return;
 
//the rest dysfunction of the program
//the code behind return can never be executed
}

[Return to Arduino Syntax Manual]