i have a proble with my project. it consist of servo motor with arduino uno. when i upload the code to arduino, motor does not rotate. i'm giving power supple by use to arduino. there arn't any errors when verifing the code. i'm first time using the servo motor so any help will be appreciated.
code:
#include <Servo.h>
Servo middle;
void setup()
{
Serial.begin(9600);
middle.attach(11); // attaches the servo on pin 11 to the middle object
}
void loop()
{
middle.write(90); // sets the servo position according to the value(degrees)sk
delay(300); // doesn't constantly update the servos which can fry them
}
Yeah you are not moving your servo motor, it's stationary at 90 degree. Try this code out. Servo Motor is attached to pin # 8 of arduino. It will also send response to Serial Terminal.
#include <Servo.h> //library for servo motor
Servo myservo; // servo motor object for its control
int ang = 0; // a variable to store the servo angle
void setup() {
Serial.begin(9600);
myservo.attach(8); // servo motor is attached to pin no 8 og Arduino
}
void loop() {
for (ang = 0; ang <= 180; ang += 5) // goes from 0 degrees to 180 degrees with a step og 5 degree
{
myservo.write(ang); // rotates the servo to rotate at specific angle
delay(50); // adding delay of 50 msec
Serial.println("Motor has started its rotation from 0 to 180 degress");
}
for (ang = 180; ang >= 0; ang -= 5) // goes from 180 degrees to 0 degrees with a step of 5 degree
{
myservo.write(ang); // rotates the servo to rotate at specific angle
delay(50); // adding delay of 50 msec
Serial.println("Motor has started its rotation from 180 to 0 degress");
}
}
now im having new issue with servo. im using 4 servos for making robotic arm. one of them is used with a claw for grabbing the objects. for this i have to place servo upside down but when i do this servo stops working, it started creating a noise but did not move. what should i do?