I created my own external 7v power source (tested stable using a multimeter). When I connect the servo to the 5v Arduino power pin, everything works, but when I connect it to my custom 7v power source, the servo moves erratically, which doesn't make any sense to me... The code is nothing special:
#include <Servo.h>
const int servo_pin=9;
Servo servo;
void setup() {
Serial.begin(9600);
servo.attach(servo_pin);
}
void loop() {
Serial.println("hello");
servo.write(90);
delay(1000);
Serial.println(servo.read());
servo.write(180);
delay(1000);
Serial.println(servo.read());
}
I am using the Adafruit Metro 328 board
Is the servo intended to run on 7V? Most small servos are only rated for 6V.
What exactly is your "7V power source"? A multimeter smooths out readings so it won't tell you if it is truly stable. It could have terrible ripple or spiking and a multimeter would never notice.
Steve
IoT_hobbyist:
Did you connect the ground together ? If not, see FAQ: How to use two power supplies. - Introductory Tutorials - Arduino Forum
I did not connect my 7v power supply to the arduino. I powered my arduino board using an usb connection to my pc. Only the signal pin of the servo is connected to the arduino.
Claire_Redfield:
I did not connect my 7v power supply to the arduino. I powered my arduino board using an usb connection to my pc. Only the signal pin of the servo is connected to the arduino.
Then you need to connect the negative of your "power source" to the Arduino GND. Without that it doesn't have a reference for the signal.
Steve