Hello, I am using a servo motor to control the rotation of my object. I know that the code for the motor to spin automatically is the following: #include <Servo.h>
Servo servowrist;
void setup() {
// put your setup code here, to run once:
servowrist.attach(7);
}
void loop() { // Loop through motion tests
alltovirtual(); // Example: alltovirtual
delay(4000); // Wait 4000 milliseconds (4 seconds)
alltorest(); // Uncomment to use this
delay(4000); // Uncomment to use this
alltomax(); // Uncomment to use this
delay(2000);
}
void alltovirtual() {
servowrist.write(0);
}
void alltorest() {
servowrist.write(0);
}
void alltomax() {
servowrist.write(180);
}
I found that there is a code that you can use a Potentiometer to control the servo here: http://www.instructables.com/id/ArduinoServoPotentiometer. However, I want to somehow try and make the user input the angle into the arduino code and then the arduino will spin it at the angle. Is that possible or would that have to involve some outside coding such as Python or C++?
Moderator edit: Fixed thread title.