Strange effects using servo

Hello,
I am a new Arduino user. I started to learn the programing and it went very smooth. I am very impresed with the possibilities of this small board. Everything was ok until yesterday when I observed the strange effects using servo. I will try to explain the problem clearly:

  1. Setup: 3 LEDs, potentiometer, passive buzzer, and servo. It is a follow up of first step excercises with Arduino published by Paul McWorther on YouTube.
  2. LEDs are connected to pin: 7,8,11. Buzzer to pin 4 and potentiometer to input A1 (including all the additional resistors of course).
  3. The program is very simple: test the potentiometer voltage, recalculate it and blink the diodes depending on the value. Nothing special. It works perfectly.
  4. The issue begins with the servo. It is connected to the pin 9. In the initial section I have: #include <Servo.h> then declaration Servo myServo; then in 'setup' section is: myServo.attach(9); It causes immedietaly problems with LEDs, which are blinking all together without any sense. When I disable the myServo.attach command with // all program is going well, no problems with LEDs.
  5. I changed the servo port from 9 to 2 and now everything is going well. Enabling the myServo.attach(2); does not cause the problems with LED. When I change pin 2 to 9 the problem returns again.
  6. I have activated the servo (SG90) sending the myServo.write commands to pin 2 and everything is OK. On pin 9 it also works, however there is a problem with LEDs blinking not properly.

Now the question:
Is pin 9 somehow related to pins 8 and 11 or is it forbidden to use it for servo? Pin 2 does not cause any problem with the software however pin 9 makes crazy effect on all the LEDs. Maybe I have got a damaged Arduino? It is Arduino One R3, However I have tested it on two different boards (classic DIL and SMD ATMega with different serial hardware) and the effect is pretty the same on both. Pin 9 makes problems, pin 2 does not.
The critical command making problems is myServo.attach(9);

Does anybody have a clue?
What am I doing wrong?

Please post a wiring diagram, and the code, using code tags.

The most common mistake with servos is to power the servo from the Arduino 5V pin. That can damage the Arduino or cause it to malfunction, so if you are doing that, power the servo separately instead (a 4xAA battery pack works). Don't forget to connect the grounds, as shown below.

If the power supply is a critical element I think you have just answered my question. I have supplied the servo directly form Arduino board, without any external PS. I was convinced it was not necessary because this was the small servo from Arduino kit. After your e-mail I have measured the voltage and it turned out it dropped down from 5V to 3,5V when servo worked, so probably it was the case. I do more tests and go back with results to confirm and close the case and to help others in similar problem if occurs.
Thank you!

Post the current sketch in code tags to see how we can help.

Don't be surprised to find you may have damaged you Arduino regulator circuit.
Arduinos are NOT a power supply centre with exception to small current reliant sensors.

Information is clearly stated in product specs if you bother to read them instead of jumping in boots and all 3/4 way through instead of the beginning.

I have tested the circuit again using the external PS for the servo. It was the only change I made and everything works fine now.
Initially I was told extra PS is not necessary and now I see it was a mistake. The servo when attached directly to the board drained too much current from it and caused all the problems with voltage and system stability.
It turned out the external PS is a mandatory add-on when using something more demanding than LED or simple sensor.
@jremington and @bluejets were 100% right.
Thank you for the help.

While on the subject, same goes for breadboards. :grinning:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.