Example Code for Arduino-PPM Mode Control

Last revision 2026/01/27

In this example, the PPM signal is created by a program, you could copy that from this passage below into Arduino IDE.

Hardware Preparation

1、6-36V External DC Power Supply x1
2、Romeo V2 x1 (or other Arduino with serial port; modify code if using other boards: change "Serial1" to "Serial")
3、12V DC geared motor with Encoder x1
4、Veyron2x25A Brush DC Motor Driver x1
5、Screw driver x1
6、Jumper wire, DuPont Line some
7、USB cable x1

Software Preparation

  • Arduino IDE (download from https://www.arduino.cc/en/software)
  • Servo library (built-in in Arduino IDE)

Wiring Diagram

Wire Wire all devices up like in the picture below:
Veyron_2x12A_PPM_wire.jpg

Other Preparation Work

Auto-set PID

On Veyron, there is a button named KEY. Use something to press it, so you can switch the working mode into SET Mode. After that, wait for a while. Veyron will set PID parameters automatically.If you want to set the PID parameters by yourself, you can set them with Directives in UART mode.
set

Sample Code

1、Open Arduino IDE, copy the code blow, then Upload it.

Note: Pin9 connected with S1

2、Press KEY to enter PPM mode.

//Name: VEYRON 2x25A DC brush deceleration motor code in PPM Mode
//Version: v0.1;
//Author: Barry from DFrobot;
//modified by Leff
// This code can be used to control the brushless motor driver in the PPM Mode;
// Details in User manual;
// make sure the working mode on the driver are in PPM Mode;
#include <Servo.h> 
Servo mymotor;
void setup()
{
mymotor.attach(9);
}
void loop()
{
mymotor.writeMicroseconds(2500); //motors rotating in clockwise direction with the highest speed;
delay(5000);                     //the motors running for 5 seconds.
mymotor.writeMicroseconds(1000); //motors stop;
delay(5000);
mymotor.writeMicroseconds(500);  //motors rotating in counter-clockwise direction with the highest speed;
delay(5000);
}

Result

The motor runs in a loop: co-rotate for 5 seconds → stop for 5 seconds → reverse for 5 seconds.

Try to change some parameters to contorl the motor.

If you need to set or read some parameters, please refer to the “In Analog Mode”.

Was this article helpful?

TOP