I am making an solar tracker using Mg995 Srrvo motors problem i am facing is that as soon as i run the program the servo start continuously rotating can any one please help me to figure it out .
i am using arduino uno and external power supply for 2 servos
below is my code :
#include <Servo.h>
//defining Servos
Servo servohori;
int servoh = 0;
int servohLimitHigh = 160;
int servohLimitLow = 20;
Servo servoverti;
int servov = 0;
int servovLimitHigh = 160;
int servovLimitLow = 20;
//Assigning LDRs
int ldrtopl = 2; //top left LDR green
int ldrtopr = 1; //top right LDR yellow
int ldrbotl = 3; // bottom left LDR blue
int ldrbotr = 0; // bottom right LDR orange
void loop()
{
servoh = servohori.read();
servov = servoverti.read();
//capturing analog values of each LDR
int topl = analogRead(ldrtopl);
int topr = analogRead(ldrtopr);
int botl = analogRead(ldrbotl);
int botr = analogRead(ldrbotr);
// calculating average
int avgtop = (topl + topr) / 2; //average of top LDRs
int avgbot = (botl + botr) / 2; //average of bottom LDRs
int avgleft = (topl + botl) / 2; //average of left LDRs
int avgright = (topr + botr) / 2; //average of right LDRs
Serial.print("avgtop = ");
Serial.print(avgtop);
Serial.print("\n");
Serial.print("avgbot = ");
Serial.print(avgbot);
Serial.print("\n");
Serial.print("avgleft = ");
Serial.print(avgleft);
Serial.print("\n");
Serial.print("avgright = ");
Serial.print(avgright);
Serial.print("\n");
delay(500);
khalifa_007:
I am making an solar tracker using Mg995 Srrvo motors problem i am facing is that as soon as i run the program the servo start continuously rotating can any one please help me to figure it out .
If your servo is able to rotate continuously then it is not possible to make it move to a position. All you can do is control its speed and direction.
If you need a servo that can be moved to a position then you need to get a regular servo and not a continuous-rotation servo.
Robin2:
If your servo is able to rotate continuously then it is not possible to make it move to a position. All you can do is control its speed and direction.
If you need a servo that can be moved to a position then you need to get a regular servo and not a continuous-rotation not-really-a-servo-anymore.
That one clearly says in several places that it is a continuous rotation servo. The MG995 is available in two versions, standard and continuous rotation. You have the wrong one.
sentence. Noun.
a set of words that is complete in itself, typically containing a subject and predicate, conveying a statement, question, exclamation, or command, and consisting of a main clause and sometimes one or more subordinate clauses.
The hyphens in "not-really-a-servo-anymore" serve to compound the proper noun "servo" with the adjectival phrase
(I would also argue that there should be a comma after "position" to indicate a pause, and possibly even an Oxford comma after "regular servo")