0
0
Arduinoprogramming~10 mins

Why project structure matters in Arduino - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define the setup function in an Arduino sketch.

Arduino
void [1]() {
  pinMode(13, OUTPUT);
}
Drag options to blanks, or click blank then click option'
Asetup
Bloop
Cmain
Dinitialize
Attempts:
3 left
💡 Hint
Common Mistakes
Using loop instead of setup here.
2fill in blank
medium

Complete the code to blink the built-in LED inside the loop function.

Arduino
void loop() {
  digitalWrite(13, [1]);
  delay(1000);
  digitalWrite(13, LOW);
  delay(1000);
}
Drag options to blanks, or click blank then click option'
AHIGH
BLOW
CINPUT
DOUTPUT
Attempts:
3 left
💡 Hint
Common Mistakes
Using LOW which turns the LED off.
3fill in blank
hard

Fix the error in the code to correctly read a button state.

Arduino
int buttonState = digitalRead([1]);
Drag options to blanks, or click blank then click option'
A13
BINPUT
CbuttonPin
DHIGH
Attempts:
3 left
💡 Hint
Common Mistakes
Using HIGH or INPUT instead of the pin variable.
4fill in blank
hard

Fill both blanks to create a dictionary-like structure using arrays for LED pins and their states.

Arduino
int ledPins[] = {2, 3, 4, 5};
int ledStates[] = [1];

void setup() {
  for (int i = 0; i < [2]; i++) {
    pinMode(ledPins[i], OUTPUT);
  }
}
Drag options to blanks, or click blank then click option'
ALOW, LOW, LOW, LOW
BHIGH, HIGH, HIGH, HIGH
C4
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong array size in loop.
Initializing states to HIGH instead of LOW.
5fill in blank
hard

Fill both blanks to create a function that turns on an LED given its pin number and duration.

Arduino
void turnOnLED([1], [2]) {
  digitalWrite(pin, HIGH);
  delay(duration);
  digitalWrite(pin, LOW);
}
Drag options to blanks, or click blank then click option'
Aint pin
Bint duration
Cduration
Dpin
Attempts:
3 left
💡 Hint
Common Mistakes
Missing parameter types.
Using wrong variable names inside the function.