Arduino uno + servo. Pins always on?!?

Hello there
This is my first post and i hole mu english is not that bad.
I’ve bought an arduino uno kit with 2 a few transistors, resistors and leds. Then i also bought a servo.
My problem is this:
I tried to make the servo move, using the sketches included in the program. At first i tried to connect the servo power, signal and gnd directly to arduino pins, but he didn’t move. Then i tried to connect the servo to 4 1.5V batteries and the signal pin directly to an arduino pin and it didn’t move (again…).
So i used a transisitor (a bc547b) to amplify the current given to the signal not using the pin, but using the current from the batteries instead. I connected the base of the transistor to the arduino and the servo began to move. The problem now is that the servo moves even when i connect the base of the transistor to an inactive arduino pin, so if before i didn’t have enough current to make the transistor drive the servo, now i’ve a servo that runs every time i connect it to ANY arduino pin. Why does it happen? Is something about how i’m using the transistor or it has something to do with some strange pin phenomenons? I’ve used arduino to drive directly small dc motors without protection diode. Did i break it?

File->Examples->Servo->Sweep

Connect Black wire of servo to Arduino Ground. Connect Red wire of servo to + side of 6V battery. Connect - side of 6V battery to Arduino Ground. Connect signal (White or Yellow) wire of servo to Arduino Pin 9.

If the servo doesn't sweep back and forth then the servo is probably bad.

Forgot 2 things: - the servo datasheet: http://www.goteckrc.com/Download/GS-3630BB.pdf - forgot to say that the servo activate in a totally random manner when powered and it moves a little in clockwise direction when i connect the power pins (then it suddendly stops)

Thanks for the answer. My servo has only 3 pins. I tried to connect altrrnatively the ground to the - of the battery and to the gnd of arduino. It only works if i connect it to the - of the battery. When activated, with the swile sketch, it moves clockwise but it doesn't move counteclockwise. It runs until it reach the end (+180) then it begins to tremble

nigliazzo: I tried to connect altrrnatively the ground to the - of the battery and to the gnd of arduino. It only works if i connect it to the - of the battery.

You have to connect it to BOTH. "Connect Black wire of servo to Arduino Ground. Connect - side of 6V battery to Arduino Ground."

Seems logic. Can this explain why i can't control 12v/450mA motors with a transistor (funny voltages between collector, base and emitter)? In fact i have always had this doubt: if i connect the base to an arduino pin, the collector to the +12v and the emitter to the ground of arduino, it's odd that i don't connect anything to the - of the 12v battery, right?

You connect the - side of all power supplies to Arduino Ground.

It doesn't explain why the servo runs when i connect the base to ANY pin (even if i don't inizialize them). Does it?

It doesn’t explain why the servo runs when i connect the base to ANY pin (even if i don’t inizialize them). Does it?

Sounds like you have miss wired your servo/battery/arduino. Below is typical servo wiring, and bottom is some simple servo test code.

// zoomkat 10-22-11 serial servo test
// type servo position 0 to 180 in serial monitor
// or for writeMicroseconds, use a value like 1500
// for IDE 0022 and later
// Powering a servo from the arduino usually *DOES NOT WORK*.

String readString;
#include <Servo.h> 
Servo myservo;  // create servo object to control a servo 

void setup() {
  Serial.begin(9600);
  myservo.writeMicroseconds(1500); //set initial servo position if desired
  myservo.attach(7);  //the pin for the servo control 
  Serial.println("servo-test-22-dual-input"); // so I can keep track of what is loaded
}

void loop() {
  while (Serial.available()) {
    char c = Serial.read();  //gets one byte from serial buffer
    readString += c; //makes the string readString
    delay(2);  //slow looping to allow buffer to fill with next character
  }

  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured string 
    int n = readString.toInt();  //convert readString into a number

    // auto select appropriate value, copied from someone elses code.
    if(n >= 500)
    {
      Serial.print("writing Microseconds: ");
      Serial.println(n);
      myservo.writeMicroseconds(n);
    }
    else
    {   
      Serial.print("writing Angle: ");
      Serial.println(n);
      myservo.write(n);
    }

    readString=""; //empty for next input
  } 
}

All done but it doesn't work anyway. I think is due to the fact that arduino pins seems ALWAYS powered. If this is true, then the signal is not controlled and is sent on every clock. In fact the servo moves all the way clockwise and then it begins to tremble or slightly move backward due (i think) to the arduino pins current instability. How can i know if the board is broken or not? Maybe i broke some current limitator or whatever that explain this strange current on powered and unpowered pin. In past experiments with dc motors i've never used a protection diode. I've also used transistors trying to give houndreds of mA of current to dc motors using arduino digital and 5v pins. (yes... I know it wasn't clever...)

I have an arduino and it controls servos just fine. Erattic servo behavior can be caused by a malformed control pulse, or improper grounding. The code I posted works just fine with my servos, so I suggest you still have bad wiring or perhaps you have damaged your servo.

I've just finished to build an h bridge for a 3v dc motor and it works using the same pins but i noticed again that the pins continue to give current to the motors (even in output mode and low state) if not properly connected. Why do they act like this?

Why do they act like this?

Perhaps you should post the code you are using. Also, h-bridges and servos are controlled totally differently. Seems like you may be confusing the two. h-bridge code can't be used with servos.

I'm not using the same code. For the servo i used the swipe code from arduino then the code written above, for the h bridge i wrote a simple code in which i use 4 pin as outputs to control 4 transistor, then i change their state every 2 seconds in the loop function. It works (2 sec "bz!", 2 sec silence, 2 sec "zb!", 2 sec silence and so on). Still i can't get how an arduino pin can let current pass from it when in output and low state WHEN improperly connected. Is it possible that a wrong wiring can cause this ( i mean IN THEORY)?

What i'm trying to say is: if i don't connect every wire in the correct manner, can arduino pins act as all of them are powered? I would like to know how to avoid future problems of the same type because i'm beginning to think i'm not aware of something basic about voltage, current or arduino pins behaviour. I mean... Everyone can do wrong sometimes and it seems strange to me that i'm the only one to have noticed such behaviour.

I mean... Everyone can do wrong sometimes and it seems strange to me that i'm the only one to have noticed such behaviour.

When making errors, there are a large range of possible results including equipment damage. You get what you get. "For the servo i used the swipe code from arduino". Never heard of servo "swipe" code, so that might be the source your problem.

Sweep not swipe. Sorry :P Problem solved with servo. Bad wiring or, to be more precise, bad powering. I'm an idiot.