Bird
0
0
Arduinoprogramming~10 mins

Why motor control is needed 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 start the motor by setting the pin HIGH.

Arduino
digitalWrite(motorPin, [1]);
Drag options to blanks, or click blank then click option'
ALOW
BINPUT
CHIGH
DOUTPUT
Attempts:
3 left
💡 Hint
Common Mistakes
Using LOW instead of HIGH to start the motor.
2fill in blank
medium

Complete the code to set the motor pin as an output.

Arduino
pinMode(motorPin, [1]);
Drag options to blanks, or click blank then click option'
AOUTPUT
BINPUT
CINPUT_PULLUP
DANALOG
Attempts:
3 left
💡 Hint
Common Mistakes
Setting pinMode to INPUT instead of OUTPUT.
3fill in blank
hard

Fix the error in the code to stop the motor by setting the pin LOW.

Arduino
digitalWrite(motorPin, [1]);
Drag options to blanks, or click blank then click option'
AOUTPUT
BHIGH
CINPUT
DLOW
Attempts:
3 left
💡 Hint
Common Mistakes
Using HIGH instead of LOW to stop the motor.
4fill in blank
hard

Fill both blanks to control motor speed using PWM.

Arduino
analogWrite(motorPin, [1]); // speed value between 0 and [2]
Drag options to blanks, or click blank then click option'
A255
B100
C0
D1023
Attempts:
3 left
💡 Hint
Common Mistakes
Using 1023 which is for analogRead, not analogWrite.
5fill in blank
hard

Fill all three blanks to create a dictionary of motor speeds for different directions.

Arduino
motorSpeeds = [1]: 255, [2]: 0, [3]: 128}
Drag options to blanks, or click blank then click option'
A"forward"
B"stop"
C"half"
D"backward"
Attempts:
3 left
💡 Hint
Common Mistakes
Using numbers as keys instead of strings.