I can't get my servo motor to work. I don't know if it's something to do with the code or if I got a broken one in my starter kit. It must be receiving power because it is buzzing when it turns on. For that reason, I immediately disconnected the board because I don't want to burn my only servo motor. I'll lay down the code, and also the circuit. Edit: picture of IMG was too big to attach. VIew circuit here
brown pin connected to GRND on breadboard (connected to arduino GRND). Red connected to 5v rail on breadboard, connected to pin 13 and initialized and turned on HIGH in code. Orange pin connected to pin 6 on arduino and used to try and turn the servo.
#include <Servo.h> //Including the Servo code library
int vRail = 13; //assigns 5v digital rail
int servoPin = 6; //assigns read/data to pin 6 (analog)
int servoDelay = 25; //this was to be used later
int pos = 0; //read var for Serial.port to be used to control position
Servo myPointer; // Create a Servo object called myPointer
void setup() {
Serial.begin(2000000);
pinMode (vRail, OUTPUT);
digitalWrite (vRail, HIGH);
myPointer.attach(servoPin);
}
void loop() {
Serial.println ("Where would you like the servo to point?");
while (Serial.available()==0){
}
pos = Serial.parseInt();
}
That picture doesn't look like a servo motor, it looks like a rotary encoder/knob
Also, your code doesn't do anything other than read in a value from the serial port. Why would you expect that to make the servo move or do anything? Look at the examples in the IDE
Please confirm that you are not powering the servo from a digital pin
vRail = 13; is the breadboard's voltage rail which is connected to the positive line (red) to the motor. Pin 6 is the analog pin being used for the motor's orange connection (what I believe should be read/write). However, the cables are color coded by brown, red and orange instead of black, red and yellow/white.
I am using the "Tower Pro Micro Servo 9g SG90" that came with my kit.
AWOL:
Are you saying the servo is connected to the pin marked A0? Are you saying that the Arduino's pin 13 is connected to 5V AND the servo? Where did you acquire the notion that this was a useful thing to do?
I got rid of the redundant cabling for the project at hand and am now showing ONLY the circuit for the motor (and an LED left behind for a different project I'm still working on). Hopefully it's easier to see what's going on.
blh64:
That picture doesn't look like a servo motor, it looks like a rotary encoder/knob
Also, your code doesn't do anything other than read in a value from the serial port. Why would you expect that to make the servo move or do anything? Look at the examples in the IDE
OK. I forgot the one most important line of code to get it to rotate. Now it reads from the serial port and turns the rotor. However, it's still buzzing and after moving 2 times, it's stopped functioning. Is it receiving too much power somehow?
AWOL:
What is the black wire on the left connected to? (I can't make it out on my phone)
You still haven't confirmed that you are not powering the servo from a digital output pin.
doh' it was totally a digital output pin. I changed the 5v rail to the 5v pin on the arduino and now it's good as gold.
They didn't explain that during during the tutorial of course.
Question: in theory if the digital output pin can have 5V output on it, why do we need the specific '5v' power instead of just a digital pin? why would that damage it?
AWOL:
Because a digital pin can only source or sink 40mA of current AT MOST.
Even a small servo could draw several hundred mA at stall.
You may already have irrepairably damaged your Arduino.
Oh well. Live and learn. That's what these boards are for. At least I didn't kill myself on a high voltage circuit. i'll test out pin 13 (the digital one used b4) and see if it still works later. For now, the other pins are working just fine. My board is a chinese clone so I didn't waste a ton of $ at least.