So I have this setup where I have and Arduino Uno, a mini Servo Motorservo motor, and a Push Buttonpushbutton. I use a single Push buttonpushbutton to control the Servo Motorservo motor to go to one position, then push it again to go back. It first goes to 0 degrees, then if you push it it goes to 180 degrees then vice versa. The problem is that it'sin its initial state (which is 0 degrees), the servo motor makes noise. Like it's running or something then it gets hot.
I've seen other servo motors that never do this. Here is my code by the way:
#include <Servo.h>
const int buttonPin = 8;
const int servoPin = 9;
int buttonState = 0;
int directionState = 0;
Servo servoOne;
int pos = 0;
void setup()
{
servoOne.attach(9);
servoOne.write(directionState);
pinMode(buttonPin, INPUT);
}
void loop()
{
buttonState = digitalRead(buttonPin);
if (directionState == 0)
{
if (buttonState == HIGH)
{
directionState = 1;
for (pos = 0; pos < 180; pos=pos+1)
pos = pos + 1) {
servoOne.write(pos);
delay(5);
}
}
}
else if (directionState == 1)
{
if (buttonState == HIGH)
{
directionState = 0;
for (pos = 180; pos > 1; pos=pos-1)
pos = pos - 1) {
servoOne.write(pos);
delay(5);
}
}
}
}
ReallyI really need all the help I can get.