Example Code for Arduino-Servo Control

Last revision 2026/01/30

In this section, we will use Arduino IDE as a Serial port communication tool to control the servo. Users can learn how to send commands to the Veyron Servo Driver to control the servo's position.

Hardware Preparation

  • Veyron Servo Driver 24-Channel
  • Micro USB cable
  • TowerPro SG90 Servo
  • Servo 5V power supply
  • 9V power supply logic

Software Preparation

Wiring Diagram

Other Preparation Work

  • Veyron requires an external power supply to support the servo.

Sample Code

void setup() {
  Serial.begin(115200);//Set the baudrate to 115200 A:1  B:1
  delay(100);//wait for baudrate setting finished
}

void loop() {
  Serial.print("#5 P750");// Channel 5 will move to 750us within 500ms
  delay(5);               //wait for first comand transmission done, if you send
  // a long command, you'd better extend it
  Serial.print("\r");    // send Carriage Return <CR>
  delay(1000);            //wait for servo go to the set position
  Serial.print("#5 P2200");// Channel 5 will move to 2200us within 500ms
  delay(5);
  Serial.print("\r");
  delay(1000);
}

Was this article helpful?

ON THIS PAGE

TOP