Professional Documents
Culture Documents
Void and Return Functions With Arduino: Mr. Michaud Marist School
Void and Return Functions With Arduino: Mr. Michaud Marist School
Arduino
Mr. Michaud
Marist School
Return Type Function
• Takes in Parameters (Most of the time)
• Returns a Value
• Example Use: Math Calculations
• Setup:
int multiply(int a, int b) {
int answer = a * b;
return answer;
}
Other Examples (Note the data types)
Calling Functions
• Create a variable equal to the function
• Print the Variable (or use it in another
calculation . . .)
Exercise
• Take a formula from Science or Math and
write a function to calculate the values.
• Example: F = ma from physics
Void Functions
• Void functions do not return a value.
• Perform a set of actions
– control pin values
– print information to screen
– initialize the board
• void setup()
• void loop()
• Can take Parameters
Example Void Function
String names [] = {"Matthew", "Mark", "Luke", "John"};