I loaded a program that turns a servo with a tilt switch, when its plugged into the computer it works fine, when i use a external power supply it wont work, it just keeps bumping but i checked the battery. It wont go the full 180 on the external power supply it just turns about 1 degree randomly. any help would be appreciated.
Grounds connected?
Can the power supply 1A ?
Yes the power supply is fine, after thinking about it, if you use the #include function to include a library, then try and use the Arduino without the computer, does this affect its ability to include that library?
No, but I'm not sure that I understand your question.
The include files and libraries are used during compiling. After compiling and linking and uploading, the Arduino runs the code on its own.
if you use the #include function to include a library, then try and use the Arduino without the computer, does this affect its ability to include that library?
No. The library is compiled and stored in the arduino.
Yes the power supply is fine,
Yes but is the ground of this power supply connected to the ground of the arduino.
It one of those 9v battery power supplies that come in the kits, when it powered through the USB it acts fine, once i use the 9v power supply it act random, turning random degrees, random directions then not turning at all and just humming. ive tried multiple arduino boards. Just completely lost on this one when i put my meter on it it draws the same amount of current from the USB and battery. dont think its my code. but ill attach it.
MBAP3.ino (938 Bytes)
When everything is okay with usb power, I assume that the grounds are connected.
The radom direction or humming indicates not enough power.
Can you get a DC power supply of 7 or 9V (perhaps 12V), a wall wart with regulated output or so. Connect that to the DC barrel jack and see what happens. I think 80% chance it will work, because the 9V battery is too weak.
Thanks for the time and thought and helping me out. Ill try that and see if i can get it to work.
This isn't 100% clear to me: you say external power supply... in servo speak we usually take that to mean that it's connected directly to the servo/s, but it sounds like you're powering the Arduino from the external supply and the servo from the Arduino ?
If so, it seems that works in principle for you since it works when using USB power. But servos can draw more current than the Arduino can supply (regardless of the strength of the supply to Arduino) so it's usually recommended that you run the servo off its own power. Of course that adds the wrinkle that you need 5-6V externally, since that's a servo's usual requirement. 4xAAs will do the trick.
See pic below. The pic makes it clear why you were asked about grounds: that of the servo external supply must connect to Arduino ground.
Thanks, Jimbo, that was exactly what my circuit lacked: A connection between Servo_GND and Arduino_GND. I had thought that connecting the servo_GND to the GND of the PSU was enough.