Complete the code to define the setup function in an Arduino sketch.
void [1]() { pinMode(13, OUTPUT); }
loop instead of setup here.The setup() function runs once when the Arduino starts. It is used to set pin modes and initialize settings.
Complete the code to blink the built-in LED inside the loop function.
void loop() {
digitalWrite(13, [1]);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}LOW which turns the LED off.To turn the LED on, you set the pin to HIGH. This sends voltage to the pin.
Fix the error in the code to correctly read a button state.
int buttonState = digitalRead([1]);HIGH or INPUT instead of the pin variable.The digitalRead() function needs the pin number variable, not a constant like HIGH or INPUT.
Fill both blanks to create a dictionary-like structure using arrays for LED pins and their states.
int ledPins[] = {2, 3, 4, 5};
int ledStates[] = [1];
void setup() {
for (int i = 0; i < [2]; i++) {
pinMode(ledPins[i], OUTPUT);
}
}HIGH instead of LOW.The ledStates array should start with all LEDs off, so all LOW. The loop runs 4 times, matching the number of pins.
Fill both blanks to create a function that turns on an LED given its pin number and duration.
void turnOnLED([1], [2]) { digitalWrite(pin, HIGH); delay(duration); digitalWrite(pin, LOW); }
The function takes two parameters: pin and duration. The code uses these to turn the LED on and off after the delay.