Advertisement

Friday, January 3, 2014

Controlling a Servo with an Arduino

Tonight at the Milwaukee Makerspace, I worked on getting my Arduino Uno to control a servo motor.  I need the servo to control the auger on my automated dog food dispenser.

I got the sketch working to control the servo over Thanksgiving weekend.  However, it only worked when the Arduino was connected to the computer over a USB cable.  When I powered it with a USB cable from a wall wart, the servo did not spin correctly.

Tonight, I did some more testing.  First, I changed the code slightly so the servo runs for one minute and shuts off.  It worked great when connected to a computer.

Next, I connect a 9v power supply to the Arduino.  It powered up but the servo never spun.  One website said that this is because the Arduino is getting interference on the RX port.  The fix is to connect the RX port to ground via a 10k resistor.  I tried that by connecting the digital RX port to ground with a resistor but it made no difference.

I used a multimeter to see how many volts the Arduino was putting out when powered by the computer and when powered by the external power supply.  On the computer, the 5v port output 5 volts.  On the external power supply, the 5v port output 4.85 volts.  I can't believe that makes a difference.

Next, I tried powering the servo from the 3.3v port instead of the 5v port when powered by the computer.  The servo still worked but would only spin in one direction.

I think I will try a 12 volt power supply next to see if that helps.