Hello all,
I am using TowerPro MG996R motor for my testing purposes. Once i make sure that the code is ok, i will buy a better motor. My aim is to move it from 0° to 50° according to analog input 0 to 5 VDC. It moves when i keep it powered on, no problem with that. Now when i power it off and the power it on again, it moves right by say 45 to 50° and then gets its position(in between 0 to 50). This changes the fixed range of the motor to move and a new range of 0 to 50 ° is obtained i.e its initial position when I start it is changed. I want it to start at exact 0 when i power on. I am using a simple knob program to start off with, but this initial position keeps worrying me.
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 50); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}
Motor SpecificationsAlso now i am powering it from UNO itself, how much power supply is needed to power it externally? i tried 5v/1Amp supply, but it loads.
Thank You