Delay when running on External Power???

I am running a servo motor with my Arduino UNO when. when i power/run the board via USB from my PC, it works perfectly. When I try to run via a 9 V battery connected to the 5.5mm DC jack it delays for up to 40 seconds (this amount of time varys). During that time the amber led is blinking but goes solid when it starts running just like it is when connected to the PC. Any ideas how to eliminate this delay? Im powering the servo through the 5v and ground pins.

#include <Servo.h> //library open
Servo servo; //servo name

int pos = 0; //stores servo postion

void setup(){
servo.attach (9); //define servo input pin
}

void loop() {

for (pos = 0; pos <= 35; pos += 1) { // goes from 0 degrees to 35 degrees
// in steps of 1 degree
servo.write(pos); // tell servo to go to position in variable 'pos'
delay(30); // waits 30ms for the servo to reach the position
}
delay(500);
for (pos = 35; pos >= 0; pos -= 1) { // goes from 35 degrees to 0 degrees
servo.write(pos); // tell servo to go to position in variable 'pos'
delay(30); // waits 30ms for the servo to reach the position
}
delay(1000);
}

Two problems.

  1. Little 9V smoke alarm batteries are too weak to successfully run any servos or motors.
  2. Running a servo from the Arduino 5V pin is a bad idea, particularly when you're powering via barrel jack. The regulator can't safely deliver enough current to run motors or servos.

Steve

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :slight_smile:

Post a schematic. If you don't have schematic capture software get a black pen and draw the circuit on a blank sheet of printer paper, photograph it an upload the photo using the "Attachments and other options" link below.

What you have posted so far tells us nothing about how the motor is connected or what is driving it.

Hi guys, Thanks for the initial observations, I have connected the servo like in the diagram below. and have a 9V going to the 5.5 mm jack. If there is a better way to connect this i'm open to trying, this is only my second time using my Arduino

Mitchell

The servo should have a separate power supply. 4 x NiMH rechargeable AA cells is good. Make sure that you connect the battery -ve to the Arduino GND.

Steve

Hi,
OPs diag.


Tom... :slight_smile:

I connected the servo too 4 AA's like said and it seemed to fix the issue, thanks guys!

That schematic may or may not be OK - depending on how the thing itself is powered. No power supply indicated!