Robotics 2.3
Robotics 2.3
Ultrasonic Sensor
At the end of the lesson 75% of the students are expected to:
Function name
It consists of a name specified to the function. It represents the
real body of the function.
Function parameter
It includes the parameters passed to the function. The
parameters are defined as the special variables, which are
used to pass data to a function.
The function must be followed by parentheses ( ) and
the semicolon ;
The actual data passed to the function is termed as an
argument.
Function Declaration
Function Declaration
void setup()
{
Serial.begin(9600);
}
void loop() {
int a = 5; // initialization of values to the variables a and b
int b = 4;
int c;
c = myAddfunction(a, b); // c will now contains the value 9
Serial.println(c); // to print the resulted value
delay(1000); // time delay of 1 second or 1000 milliseconds
}
int myAddfunction(int i, int j)
{
int sum;
sum = i + j;
return sum;
}
Function Declaration
void setup()
{
Serial.begin(9600);
}
void loop() {
int a = 5; // initialization of values to the variables a and b
int b = 4;
int c;
c = myAddfunction(a, b); // c will now contains the value 9
Serial.println(c); // to print the resulted value
delay(1000); // time delay of 1 second or 1000 milliseconds
}
int myAddfunction(int i, int j)
{
int sum;
sum = i + j;
return sum;
}