Community project

AI Target-Following Drone

Photo of AI Target-Following Drone
Generated with AI

khaled07abdoul

Published November 29, 2026

This project builds a four-axis servo controller on Arduino Uno that accepts commands over serial to position high-torque metal gear servos. The guide covers wiring four MG90D servos to PWM pins, adding power conditioning with a capacitor, and integrating an LED status indicator. Builders will receive a complete wiring diagram, parts list with power specifications, and the full firmware source code.

The controller uses pulse-width modulation to command each servo independently across the 1200–1800 microsecond range, with serial commands to arm the system, center all axes, and move individual servos to target positions. Assembly involves securing bench mounts, routing control signals cleanly, and verifying servo travel before operation. This foundation supports adding external targeting logic or sensor feedback in future iterations.

Wiring diagram

Wiring diagram for AI Target-Following Drone
Loading diagram…

Gather all the parts

QtyComponent
1

MG90D High-Torque Metal Gear Micro Servo

13g digital micro servo with metal gears, an aluminum output shaft, and double ball bearings, giving noticeably more torque and speed than a standard MG90S or SG90. Wired and controlled exactly like any hobby servo: 3-wire PWM at 4.8-6.6V, drop-in compatible with the Arduino Servo library.

1

MG90D High-Torque Metal Gear Micro Servo

13g digital micro servo with metal gears, an aluminum output shaft, and double ball bearings, giving noticeably more torque and speed than a standard MG90S or SG90. Wired and controlled exactly like any hobby servo: 3-wire PWM at 4.8-6.6V, drop-in compatible with the Arduino Servo library.

1

MG90D High-Torque Metal Gear Micro Servo

13g digital micro servo with metal gears, an aluminum output shaft, and double ball bearings, giving noticeably more torque and speed than a standard MG90S or SG90. Wired and controlled exactly like any hobby servo: 3-wire PWM at 4.8-6.6V, drop-in compatible with the Arduino Servo library.

1

MG90D High-Torque Metal Gear Micro Servo

13g digital micro servo with metal gears, an aluminum output shaft, and double ball bearings, giving noticeably more torque and speed than a standard MG90S or SG90. Wired and controlled exactly like any hobby servo: 3-wire PWM at 4.8-6.6V, drop-in compatible with the Arduino Servo library.

1

LED

Red, 5 mm

Standard 3mm/5mm through-hole LED. A current-limiting series resistor is added automatically.

1

Resistor

330 ohm, 1/4 W

Through-hole resistor (current-limiting in series with an LED)

1

USB-C 5V Adapter

USB-C wall adapter delivering regulated 5 V to the board's USB or VBUS rail. Default wired power source for desktop / stationary projects.

1

Electrolytic Capacitor

1000 uF, 10 V

Radial aluminium electrolytic capacitor bought by value and voltage rating, such as 10 µF, 100 µF or 1000 µF 10 V. It is polarised: the + lead goes to the higher voltage and the - lead, marked by the stripe on the sleeve, to the lower voltage or ground. It is mostly used for bulk filtering across a power rail, with a voltage rating comfortably above the rail.

Assemble it in 6 steps

1. Secure the bench mounts

Clamp two lightweight pan-and-tilt brackets to the bench. Use one pair of MG90D servos for a lightweight camera mock-up and the other pair for the LED. Leave horns off for initial centering. Support the camera and fiber cable separately; do not load these small servos with the unknown camera assembly.

  • This is not flight hardware. Keep fingers away from moving linkages.

2. Wire the four control signals

With all power disconnected, connect camera pan SIGNAL to D3, camera tilt to D5, LED pan to D6, and LED tilt to D9. These wires carry aiming commands.

3. Connect separate motor power

Use the regulated 5 V 4 A adapter with an insulated USB-C power breakout cable. Connect its +5 V output to all four red servo VCC wires. Connect its ground to all four brown/black servo ground wires AND Uno GND. Use a screw-terminal distribution connection, not thin breadboard power tracks. The Uno gets its own power through computer USB. Never join adapter +5 V to Uno 5V, VIN, or USB power.

  • Use an enclosed certified adapter; never open it or work on mains wiring. Disconnect servo power immediately if any motor buzzes, binds, or becomes hot.

4. Add the power reservoir

Connect the 1000 uF capacitor across the servo supply near the distribution point: plus to servo +5 V, striped negative lead to ground. Insulate exposed connections.

  • Reversed electrolytic capacitor polarity can cause rupture.

5. Wire the symbolic pointer

Connect D7 through the 330 ohm resistor to the LED long leg (anode). Connect the LED short leg/flat side to ground. Attach the LED to its tilt bracket with flexible wires and enough slack for movement. This is an indicator, not a focused projector.

6. Fit centered horns and check travel

Support both mounts. After electrically centering the servos, disconnect motor power before fitting horns at the middle position. Move in small increments and check cable slack and mechanical clearance. Power can cause an initial centering jump. Removing control pulses does not physically restrain a mount; support it before stopping.

Review all connections

1. Connections between "camera_pan" and "Arduino"

Functioncamera_panArduino
pwmSIGNALGPIO 3
powerVCC5V
groundGNDGND

2. Connections between "camera_tilt" and "Arduino"

Functioncamera_tiltArduino
pwmSIGNALGPIO 5
powerVCC5V
groundGNDGND

3. Connections between "led_pan" and "Arduino"

Functionled_panArduino
pwmSIGNALGPIO 6
powerVCC5V
groundGNDGND

4. Connections between "led_tilt" and "Arduino"

Functionled_tiltArduino
pwmSIGNALGPIO 9
powerVCC5V
groundGNDGND

5. Connections between "servo_supply" and "Arduino"

Functionservo_supplyArduino
power+5V5V
groundGNDGND

6. Connections between "reservoir" and "Arduino"

FunctionreservoirArduino
power+5V
ground-GND

7. Connections between "led_resistor" and "Arduino"

Functionled_resistorArduino
digitalP1GPIO 7
digitalP2 → LED ANODEEXT

8. Connections between "pointer" and "Arduino"

FunctionpointerArduino
groundGNDGND

Deploy the firmware

#include <Arduino.h>
#include <Servo.h>
#include <string.h>
Servo axes[4];
const uint8_t pins[4]={3,5,6,9};
int position[4]={1500,1500,1500,1500};
int target[4]={1500,1500,1500,1500};
bool armed=false;
char line[48];
uint8_t used=0;
bool overflow=false;
unsigned long lastStep=0;
void stopMotion(){
  for(uint8_t i=0;i<4;i++) { axes[i].detach(); target[i]=position[i]; }
  digitalWrite(7,LOW); armed=false;
}
void command(){
  if(!strcmp(line,"ARM")){
    for(uint8_t i=0;i<4;i++){axes[i].writeMicroseconds(position[i]);axes[i].attach(pins[i],1200,1800);}
    armed=true; Serial.println(F("OK armed")); return;
  }
  if(!strcmp(line,"STOP")){stopMotion();Serial.println(F("OK stopped; mounts may go limp"));return;}
  if(!strcmp(line,"CENTER")){
    for(uint8_t i=0;i<4;i++)target[i]=1500;
    Serial.println(F("OK center requested"));return;
  }
  if(!strcmp(line,"LED 0")){digitalWrite(7,LOW);Serial.println(F("OK"));return;}
  if(!strcmp(line,"LED 1") && armed){digitalWrite(7,HIGH);Serial.println(F("OK"));return;}
  int axis=0,pulse=0; char extra;
  if(sscanf(line,"SET %d %d %c",&axis,&pulse,&extra)==2 && axis>=0 && axis<4 && pulse>=1200 && pulse<=1800 && armed){
    target[axis]=pulse;Serial.println(F("OK"));return;
  }
  Serial.println(F("ERR: ARM | STOP | CENTER | LED 0/1 | SET axis(0..3) us(1200..1800)"));
}
void setup(){
  pinMode(7,OUTPUT);digitalWrite(7,LOW);
  Serial.begin(115200);
  Serial.println(F("Bench controller ready, outputs disabled. ARM enables servos."));
}
void loop(){
  while(Serial.available()){
    char c=Serial.read();
    if(c=='\r')continue;
    if(c=='\n'){
      line[used]=0;
      if(overflow)Serial.println(F("ERR line too long"));else if(used)command();
      used=0;overflow=false;
    }else if(used<sizeof(line)-1)line[used++]=c;else overflow=true;
  }
  unsigned long now=millis();
  if(armed && now-lastStep>=20){
    lastStep=now;
    for(uint8_t i=0;i<4;i++){
      int difference=target[i]-position[i];
      position[i]+=constrain(difference,-4,4);
      axes[i].writeMicroseconds(position[i]);
    }
  }
}

Remix this project

Make it yours in one click

Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.

Open in Schematik