Example Code for Arduino-UART Mode Control
Last revision 2026/01/27
Here, in UART mode. There are two things you can do. First one is very useful: to set some parameters and read what’s inside of Veyron. Second, you could control the motor by a program in the interface. Ready? So, let’s get start.
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)
- DFRobotVeyronBrushed library (download from https://github.com/DFRobot/DFRobotVeyronBrushed; unzip and place in Arduino IDE library folder)
Wiring Diagram
Wire Wire all devices up like in the picture below:

Other Preparation Work
1、Download needed program
Please go to Github, download the needed program, unzip the file-Zip and put them in the folder of Arduino IDE library. As showed below:


Then, open Arduino IDE, you could find the needed program.

2、Auto-Set PID in SET mode
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.

3、Check Serial connected
Once you power on, the indicator will light up, what dose it mean? Please take a look at “1.5 Indicator definitions” . Press the KEY to go into UART mode, then checking some basic info like**”Serial Port”, “Board”(here, it’s Leonardo), “Baud rate”(57600).**

Open the “C_CheckSerial”, and upload it to the Leonardo.

Then open the Port Window. If you receive the “BDC, Connection Good! ”, then you can go on. If not, check the wire or other steps.

Result
1、Upload the “A_Configuration ”
This step is to set some parameters ”encoder line” and ”gear ratio”, you can find them in the program.
2、Upload the“B_RunMotor”
Once you upload the example, the motor will run in this way: co-rotating for 2 seconds ---stop for 2 seconds---reverse running for 2 seconds--- stop for 2 seconds. It will loop this.
Was this article helpful?
