Recall & Review
beginner
What is the main purpose of using functions in Arduino code?
Functions help organize code into smaller, reusable blocks. This makes the code easier to read, understand, and maintain.
Click to reveal answer
beginner
How do you define a function in Arduino?
You write the return type, function name, parentheses with parameters (if any), and curly braces containing the code. For example:<br>
void blinkLED() {<br> digitalWrite(LED_BUILTIN, HIGH);<br> delay(1000);<br> digitalWrite(LED_BUILTIN, LOW);<br> delay(1000);<br>}Click to reveal answer
beginner
What is the difference between 'void' and other return types in function definitions?
'void' means the function does not return any value. Other return types like 'int' or 'float' mean the function sends back a value when it finishes.
Click to reveal answer
beginner
Why is it helpful to call functions inside the loop() function in Arduino?
Calling functions inside loop() keeps the main code clean and easy to follow. It also allows repeating tasks by just calling the function multiple times.
Click to reveal answer
beginner
Can functions in Arduino take inputs? How?
Yes, functions can take inputs called parameters. You put them inside the parentheses when defining the function. For example:<br>
void blinkLED(int delayTime) {<br> digitalWrite(LED_BUILTIN, HIGH);<br> delay(delayTime);<br> digitalWrite(LED_BUILTIN, LOW);<br> delay(delayTime);<br>}Click to reveal answer
What keyword is used to define a function that does not return a value in Arduino?
✗ Incorrect
The keyword 'void' means the function does not return any value.
Where do you usually call your functions to run repeatedly in an Arduino sketch?
✗ Incorrect
The loop() function runs repeatedly, so calling your functions inside loop() makes them run over and over.
What is the benefit of breaking code into functions?
✗ Incorrect
Functions organize code into smaller, reusable parts, making it easier to read and maintain.
How do you pass information to a function in Arduino?
✗ Incorrect
You pass information to functions by adding parameters inside the parentheses when defining or calling the function.
Which of these is a correct function call in Arduino?
✗ Incorrect
To call a function, you use its name followed by parentheses, like blinkLED().
Explain how functions help organize Arduino code and give an example of a simple function.
Think about how breaking tasks into small steps makes your code easier to manage.
You got /3 concepts.
Describe how to pass a value to a function and use it inside the function in Arduino.
Consider how you tell a friend exactly what to do by giving details.
You got /3 concepts.