Complete the code to define the setup function that runs once.
void [1]() {
// initialization code here
}The setup() function runs once when the Arduino starts. It is used to initialize settings.
Complete the code to define the loop function that runs repeatedly.
void [1]() {
// code to run repeatedly
}The loop() function runs over and over after setup() finishes. It contains the main code that keeps running.
Fix the error in the code to ensure the loop function runs repeatedly.
void setup() {
// initialization
}
void [1]() {
// repeated code
}The Arduino expects a function named loop() to run repeatedly. Using any other name will not work.
Fill both blanks to create a program that blinks an LED on pin 13.
void [1]() { pinMode(13, [2]); } void loop() { digitalWrite(13, HIGH); delay(1000); digitalWrite(13, LOW); delay(1000); }
The setup() function runs once to set pin 13 as an output using OUTPUT. The loop() function then blinks the LED.
Fill all three blanks to create a program that reads a button on pin 2 and turns on an LED on pin 13 when pressed.
void [1]() { pinMode(13, [2]); pinMode(2, [3]); } void loop() { int buttonState = digitalRead(2); if (buttonState == HIGH) { digitalWrite(13, HIGH); } else { digitalWrite(13, LOW); } }
The setup() function sets pin 13 as OUTPUT for the LED and pin 2 as INPUT for the button. The loop() reads the button and controls the LED accordingly.
