Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to include the Servo library.
Arduino
#include [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes instead of angle brackets
Incorrect capitalization of 'Servo.h'
Omitting the #include directive
✗ Incorrect
The Servo library is included with #include <Servo.h> using angle brackets and correct capitalization.
2fill in blank
mediumComplete the code to create a Servo object named myServo.
Arduino
Servo [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different object name
Missing the semicolon
Using a reserved keyword as the name
✗ Incorrect
The Servo object is named myServo as per the instruction.
3fill in blank
hardFix the error in attaching the servo to pin 9.
Arduino
myServo.[1](9);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using connect instead of attach
Using begin or start which are not Servo methods
Omitting the pin number
✗ Incorrect
The correct method to attach a servo to a pin is attach(pinNumber).
4fill in blank
hardFill both blanks to write the servo to 90 degrees inside loop.
Arduino
void loop() {
myServo.[1]([2]);
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using attach instead of write
Using 45 instead of 90
Omitting the angle value
✗ Incorrect
Use myServo.write(90); to set the servo angle to 90 degrees.
5fill in blank
hardFill all three blanks to create a servo, attach it to pin 10, and write 180 degrees.
Arduino
Servo [1]; void setup() { [1].[2](10); [1].write(180); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different object names inconsistently
Using wrong method names like connect or start
Forgetting to attach before writing
✗ Incorrect
Create a Servo object named myServo, attach it to pin 10, and write 180 degrees to set the position.
