Match the following comments to the appropriate line of code for controlling a s
ID: 2074793 • Letter: M
Question
Match the following comments to the appropriate line of code for controlling a servo motor G. //activate the built-in servo function library Aint pot-0; B. val analogRead (pot) C. servol.write (val) D.#include E. servol.attach (9) F int val; G. Servservo1 ; H. val-map (val, 0, 1023, 0, 180) nitialize the servo object to control the servio //declare the pin associated with the potentiometer·'pot' declare the variable used to store values from the potentiometer // associate the pin to which the servo object is associated .D // read the potentiometer value and store it in a variable // scale the potentiometer reading value to degrees send the new position value to the servo objectExplanation / Answer
1. //activate built in servo library function ----> #include <servo.h> D
2. //initialize the servo object to control the servo --> Servo servo1 ; G
3.//declare the pin associated with potentiometer 'pot' --> int pot = 0 ; A
4. //declare variable to store values from potentiometer --> int val; F
5. //associate pin to which servo object is associated --> servo1.attach(9) ; E
6. //read potentiometer value and store it in variable --> val =AnalogRead(pot) ; B
7. //scale the potentiometer reading values to degrees --> val = map(val, 0, 1023, 0, 180) ; H
8. //send the new position to servo object --> servo1.write(val); C
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.