Having problems with my servo's

I am building a car using an Arduino. I have a 11.2 V battery that I connect to my Arduino, but the servo's keep pausing in the after about one second (I am using FS90R continuous servo's) , and after another second they turn on again. If I connect the Arduino to my laptop, the servo's do turn continuously but move really slow. It is my first time using the Arduino, so I don't know things I can try.

#include <Servo.h>
#define LED_GROEN 4
#define LED_ROOD 2
#define LED_GEEL 3


Servo servolinks;
Servo servorechts;

// defines pins numbers
const int trigPin = 7;
const int echoPin = 5;
// defines variables
long afstand_ms;
int afstand_cm;


void setup()
{
  servolinks.attach(9);
  servorechts.attach(10);
  servolinks.write(0);
  servorechts.write(180);
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
  pinMode(echoPin, INPUT); // Sets the echoPin as an Inputer
  Serial.begin(9600); // Starts the serial communication
  pinMode(LED_GROEN, OUTPUT);
  pinMode(LED_ROOD, OUTPUT);
  pinMode(LED_GEEL, OUTPUT);
}


void loop()
{
  digitalWrite(LED_GROEN, LOW);
  digitalWrite(LED_GEEL, LOW);
  digitalWrite(LED_ROOD, LOW);

  // Clears the trigPin
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  // Sets the trigPin on HIGH state for 10 micro seconds
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(2);
  digitalWrite(trigPin, LOW);
  // Reads the echoPin, returns the sound wave travel time in microseconds
  afstand_ms = pulseIn(echoPin, HIGH);
  // Calculating the distance
  afstand_cm = (afstand_ms * 0.034) / 2;
  // 

  if (afstand_cm < 20)
  {
    digitalWrite(LED_ROOD, HIGH);
    servolinks.write(60);
    servorechts.write(60);
    

  }
  else if (afstand_cm < 50)
  {
    digitalWrite(LED_GEEL, HIGH);
    servolinks.write(60);
    servorechts.write(120);
    
  }
  else if (afstand_cm < 100)
  {
    digitalWrite(LED_GROEN, HIGH);
    servolinks.write(0);
    servorechts.write(135);
    
  }
  else
  {
  servolinks.write(0);
  servorechts.write(150);
  }

}

The servos need their own power supply - usually 5vdc or 6vdc.

I suspect you are using the Arduino as a power supply for the servos... The "pausing in the after about one second" is the Arduino slowly dying from sourcing more current (servo = 100 mA, no load) than recommended (Arduino pin = 40mA maximum).

Okay so do I need two batteries? can I just connect my 11.2 V battery to the servo and uses the digital pin for the input? Or do I need a completely different battery, I would really like to use the one that I have already. Is there maybe a way around this, so I don't need a 6 vdc battery?

Schematics please.....

I hope Aref is a drawing mistake.

You didn't show how you did power the servos.
Can't power them from the 5volt pin of the Uno R3.

The use of D9, D10 for the servos made me think you're also using a motorshield.
If you did, then the same story applies. Can't power the servos from that shield.

That pausing of the servos is the Uno restarting every time from an overheating 5volt regulator, which won't last long...
Leo..

I don't see the + power wire for the servos, you need an 11.2 to 6 volt buck converter that can supply current for 2 servos (3 Amps?).

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.