The connection of the servo motor using Arduino is as follows:

Connect the black wires on the two servo motors to the GND on the Arduino

Connect the red wires on the two servo motors to the 5V pin on the Arduino

Connect the yellow wire on the first motor to pin 8 on the Arduino

Connect the yellow wire on the second motor to pin 9 on the Arduino

servo motor,servo motor price list, servo motor online store

Sample source code:

#include "Servo.h"

#define PIN_SERVO 9

#define PIN_KNOB A0

Servo servo; // creates servo object to control the SG90 servo

int value_knob = 0; // will be used to store the value of the potentiometer/knob

int value_servo = 0; // will be used to control the servo => should be between 5 and 175 degrees

void setup()

{

  servo.attach(PIN_SERVO); // assigns pin 9 to the servo object

}

void loop()

{

  value_knob = analogRead(PIN_KNOB); // reads value of the knob/potentiometer. Return value will be between 0 and 1023.

  value_servo = map(value_knob, 0, 1023, 5, 175); // will map knob value range to servo value range

  servo.write(value_servo); // shaft of servo will start to rotate. value_servo is interpreted as an absolute position.

  delay(20); // give servo some time to rotate

}