Arduino Uno and servo

Hello. Im trying to get a higher torque servo to work with my Uno, but cant seem to figure it out. Below are pictures of my setup. Smaller servo plugs into Arduino, and runs a loop with no problems. Bigger servo connected directly to 4 AA batteries and yellow wire into port 9, servo wont move. Any thoughts?


Your second picture has no ground connection to the Uno.

1 Like

Thank you! Do you have any idea how I can ground it?

Connect the black wire from the battery to a pin marked "Gnd" on the Uno, and to the servo.

1 Like


Connection for servo external power supply

1 Like

That did it. Thank you so much.

Im going to further complicate this by trying to connect a light sensor so that when the light sensor detects light, the servo will open, and then when the light goes out, the servo will close. Can I do that on th board or do I need to use a breadboard? Im still new to Arduino, only had it for 3 days.

You should get a solderless breadboard and/or prototyping PCBS.

1 Like

You can use a LDR without a breadboard (connect directly to the Uno) by using the internal pullup on the analog input as the LDR load resistor if the sensitivity is OK.

image

const byte ldrPin = A0;

void setup()
{
   Serial.begin(115200);
   // enable internal pullup on pin A0
   pinMode(ldrPin, INPUT_PULLUP);
}

void loop()
{
   static unsigned long timer = 0;
   unsigned long interval = 1000;
   if (millis() - timer >= interval)
   {
      timer = millis();
      int ldrValue = analogRead(ldrPin);
      Serial.print("Light reading = ");
      Serial.println(ldrValue);
   }
}
1 Like

Just connect the black wire from the battery adapter to any ground pin on the board.

1 Like

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