Thursday, August 25, 2011

Task 9 - function DoubleInt()

/*
 * Project:     DoubleInt_621Task09
 * Author:     Jane-Maree Howard
 * Date:          Tuesday 30/08/2011
 * Platform:   Arduino 22
 * Purpose:    To demonstrate a simple function taking a parameter,
                           with result outputted to Serial Monitor (SM)
 * Operation:  Description: calls a function DoubleInt(), taking an
                             integer as parameter, which returns a number double
                             the value of the parameter.                  
                            Declare: integer myInt; DoubleInt(int iInt)
                            Setup(): SM@9600baud;
                                              call DoubleInt() with an integer & a variable            
                            Loop(): empty                  
 */

void setup()  
{
  Serial.begin(9600);  //SM @ 9600baud
  int myInt = 23;
  Serial.println(DoubleInt(365));
  Serial.println(DoubleInt(myInt));
}//end setup()

void loop()                    
{  //empty
}//end loop()

// DoubleInt() - doubles parameter
int DoubleInt(int iInt)
{
  int j = iInt*2;
  return j;
}//DoubleInt()
//END














No comments:

Post a Comment