Bluetooth® LE 360° Servo Motor Control
Wireless speed and direction control. Powered by Zephyr®.
Wireless MCU | Bluetooth LE | Clockwise (CW) / Counterclockwise (CCW)
Set up Zephyr · Import · Build · Flash · Run with MBD
Contents
- Introduction
- Hardware Setup
- Zephyr Software Setup
- Application Architecture and Control Principles
- Demo Setup and Operation
- Validation and Troubleshooting
1. Introduction
Control a compatible 360° continuous-rotation servo wirelessly from the
Microchip Bluetooth Data (MBD) app. Choose a speed command, select clockwise (CW)
or counterclockwise (CCW) direction, and start or stop rotation. The board
translates Bluetooth LE commands into hardware-generated PWM.
Speed control in both directions: Move the MBD slider to set the rotation
speed command from 0 to 100 in either CW or CCW. Select direction
separately, then use START/STOP to run or stop. Speed 0 commands neutral;
the scale is not measured RPM.
Tested hardware: Tower Pro MG996R 360° continuous-rotation servo, operated at 5 V.
Disclaimer
This example is provided “AS IS” as a starting point for development and
self-support. Verify the servo's electrical ratings and mechanical behavior
before use. Firmware speed values are commands, not measured RPM.
2. Hardware Setup
Bill of materials
📌 Important — Servo power supply
Use a suitable regulated external servo supply if the board's available current
is insufficient. Verify the servo's current requirements, including stall
current, and connect the external supply ground to board ground.
Model names alone do not establish that a servo is continuous-rotation; confirm
the exact variant. For position control, use the
180° application.
Wiring
Connect the 360° continuous-rotation servo to mikroBUS header 2 as shown below.
The setup used here takes PWM, 5 V, and GND from that header.

| PIC32-BZ6 Curiosity connection |
Servo connection |
Purpose |
| mikroBUS header 2 — PWM |
PWM / signal input |
PC11, routed as TCC1 WO1 |
| mikroBUS header 2 — 5V |
Servo supply input |
Only for a servo rated for 5 V and within the board power budget |
| mikroBUS header 2 — GND |
Servo ground |
Common signal and power reference |
flowchart LR
subgraph H["mikroBUS header"]
P["PWM"]
V["5V"]
G["GND"]
end
subgraph S["360° servo"]
SP["Signal"]
SV["Supply"]
SG["Ground"]
end
P --> SP
V --> SV
G --> SG
style P fill:#dbeafe,stroke:#2563eb,color:#1e3a8a
style V fill:#fee2e2,stroke:#dc2626,color:#7f1d1d
style G fill:#e2e8f0,stroke:#475569,color:#0f172a
Loading
⚠️ Warning
Check the board and servo current ratings, including servo stall current. Do
not assume the board's 5 V header can supply every servo. If an external supply
is required, connect its ground to board ground and avoid tying its output to
the board's 5 V rail unless the power arrangement explicitly permits it.
Never connect a 5 V supply to the MCU signal pin.
Connect wiring with power removed. Verify servo pin functions from its datasheet;
wire colors are not a reliable specification. Start with the servo unloaded and
the rotating parts clear. Hardware photos can be added alongside these diagrams
without changing the documented pin mapping.
3. Zephyr Software Setup
3.1 Prerequisites
Complete the Zephyr Wireless environment setup
using either of the two supported workflows:
Use those guides for host tools, workspace and SDK installation, Microchip
libraries, OpenOCD, and programmer-mode setup. Use a Zephyr checkout containing
the released Transparent UART service/server and SDK 0.17.4 for this
application.
Supported board: PIC32-BZ6 Curiosity only — pic32wm_bz6204_curiosity.
Setup guide and supporting references
Complete the environment setup before importing the application. The Transparent
UART, PWM, and testing links below are supporting references, not extra
installation steps.
3.2 Import the application
Clone into the workspace
After completing the setup prerequisites, clone the application from your
workspace's applications directory:
git clone https://github.com/MicrochipTech/Bluetooth_LE_360_Servo_Motor_Control.git
Run these commands in the intended workspace, not an unrelated shared workspace.
The application repository alone
does not contain Zephyr, its modules, or the toolchain.
💡 Tip
The branch name alone is not enough: an older local checkout of the same branch
may not contain the released Transparent UART service/server. Check the commit
and ensure your build selects that checkout if multiple Zephyr packages are
installed.
Workbench
Follow Import existing application in Workbench.
Select the cloned applications\Bluetooth_LE_360_Servo_Motor_Control folder.
Choose board pic32wm_bz6204_curiosity, SoC qualifier
pic32cx2051bz62132 if requested, and SDK 0.17.4.
CLI
No IDE import is required. For this CLI workflow, copy the application folder or
clone the repository inside the Zephyr checkout's samples directory. The build
commands below assume it is at
~/zephyrproject/zephyr/samples/Bluetooth_LE_360_Servo_Motor_Control.
To clone it directly into that location:
cd ~/zephyrproject/zephyr/samples
git clone https://github.com/MicrochipTech/Bluetooth_LE_360_Servo_Motor_Control.git
See the Zephyr Wireless CLI workflow
for workspace and shell setup.
3.3 Application configuration
This application builds on Transparent UART available
through Zephyr Wireless,
using the Transparent UART sample.
It uses the Transparent UART service/server for Bluetooth LE communication and adds the
360° servo command interface and PWM speed, direction, and start/stop control.
Zephyr uses Kconfig for features, devicetree for routing, and its PWM API for
pulse updates.
| Layer |
Configuration / source |
Role |
| Bluetooth LE + Transparent UART |
prj.conf |
Enables the Bluetooth LE peripheral, Transparent UART service/server, dynamic GATT, and buffers |
| Servo type |
Kconfig |
Selects the 360° application |
| PWM route |
BZ6 board overlay |
pwm-servo alias, TCC1 channel 1, PC11, 20,000,000 ns period |
| Command integration |
main.c |
Advertising, Transparent UART event dispatch and serial bridge, and servo command forwarding |
| Speed-to-pulse mapping |
Servo implementation |
State/range validation, ACKs/responses, and pwm_set_dt() |
| Command definitions |
Servo header |
Opcodes, request/response IDs, direction, and start/stop values |
The configuration enables the Bluetooth LE peripheral, Transparent UART
service/server, dynamic GATT database, GPIO, and PWM.
Bluetooth LE is configured for one connection, a target ATT MTU of 247, and
16 Transparent UART receive buffers of 244 bytes. The actual MTU is negotiated
with the phone.
Persistent bond storage is not enabled.
3.4 Build the application
Workbench
Follow Build the application in Workbench
using the board and SDK selected during import. Select a Zephyr checkout
containing the released Transparent UART service/server.
CLI
Refer to Zephyr Wireless — Building sample applications.
For this repository, use the following board and source path.
From the Zephyr checkout directory: