Go Down

Topic: Questions about Programming a Servo Motor [Solved] (Read 1 time) previous topic - next topic

lastchancename

With a power supply, or larger battery?

Keep you 0V lines common, and don't short anything!
Your servo datasheet will note the stall current requirement- that's the minimum you need.

If the servo stalls, it could drag the supply down, which might reset the arduino.
Experienced responders have a nose for laziness, (they were beginners once)... Sure, there are trolls, chest-beaters, and pretenders - but the help you'll get here is about as good as it gets - if you try to help youself!.

spencerkim

I want to know about both ways, so I could choose which one to use for my Arduino Uno servo motor connection.

spencerkim

Should I use a 6V battery for my servo motor?

UKHeliBob

4 AA batteries (not rechargeable ones) in series usually works OK
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

spencerkim

Do I connect them to the Arduino or the actual 5V and breadboard?

groundFungus

Connect the plus from the battery pack ONLY to the plus power wire of the servo.  Connect the minus from the battery pack to the minus power wire of the servo AND the ground of the Arduino.

spencerkim

I tried connecting 4 AA batteries directly to the servo motor. However, it didn't work. Is there a problem with my coding? I am trying to make the servo motor turn 90 degrees when the water is sensed and come back to the original position when the water goes away.

groundFungus

Did you connect the negative of the battery to the servo ground and the Arduino ground?

spencerkim

There is only one wire connecting to the negative of the battery. Can you upload a diagram to explain what you mean by that?

UKHeliBob

Connect the negative of the battery to the servo and also to a GND pin on the Arduino so that the 2 systems have a common point of reference
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

groundFungus

#40
Nov 10, 2019, 06:01 pm Last Edit: Nov 10, 2019, 06:01 pm by groundFungus
Here is a diagram.


spencerkim


spencerkim

I tried doing that, but it still didn't work the way that I want it to. Is there a problem with my coding?

DuffleBag

#43
Nov 11, 2019, 11:03 pm Last Edit: Nov 11, 2019, 11:30 pm by DuffleBag
Edit: I stand corrected about PWM... but still, this board should be able to drive that servo (with risk)

I've connected similar micro servos to my Arduino directly and it's worked just fine.  

Yes, a separate power supply is safer, and smarter, but if you're getting confused (which it sounds like) it's added complication that makes troubleshooting harder.

One thing I am seeing is that you are trying to drive your servo from pin 2, which is not PWM for a standard uno.  Servos need to be plugged into a PMW pin to function correctly.

My suggestion:

Try picking a different signal pin, one that has a "~" in front of it on the board. 3, 9, 10, 11 maybe?  

And also power your servo (5v & gnd) from the board like you had originally, and see if it works.

If it does:

Dig out an old USB phone charger and hack apart an old USB cable to power that servo directly.  Don't forgot to connect the ground back to the board.  Or do nothing, and know you're taking a chance and might fry your board one day.

UKHeliBob

Quote
Servos need to be plugged into a PMW pin to function correctly.
Not true
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Go Up