Go Down

Topic: How to return a value from a void function and use it inside the void loop? (Read 21031 times) previous topic - next topic

Delta_G

I think hitting a C++ tutorial on functions would do this OP a LOT of good. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

0011

Thank you for your comments. I will come back to you guys here, once I understand.

JMD1

Dude, by seeing the code you have provided I can tell you that you have forgotten to start the serial communication, Serial.begin(9600);
Second mistake, you must call the function. Calling a function means to "trigger" it.
Example:
 
void setup(){
}

void loop(){
  int x =0;
  if( x==0){
    cheesecake();  //cheesecake() calls the   
                               //function called cheesecake
  }
}

void cheesecake(){               
 //after calling cheesecake you come here
 //here do whatever you want
}

Go Up