小编
Published2025-10-15
In this article, we’ll explore how to control servo motors using Bluetooth and Arduino. Learn the basics of setting up Bluetooth communication, programming the Arduino, and fine-tuning your project to create smooth and reliable servo motor control from a distance.
Bluetooth control, servo motor, Arduino, wireless control, Bluetooth communication, Arduino project, servo motor control, DIY electronics, remote control, robotics, IoT, Bluetooth module.
Introduction to Bluetooth Control of Servo Motors with Arduino
In today’s world, wireless technology is becoming increasingly vital in numerous applications, especially in robotics and automation. One of the most accessible ways to control devices remotely is through Bluetooth communication. And when it comes to controlling hardware like servo motors, Arduino makes it easy for hobbyists and engineers alike to build sophisticated systems.
In this guide, we will explore how you can control a servo motor using a Bluetooth connection, all powered by an Arduino. You’ll be able to create a remote-controlled system where the servo motor's position is manipulated via a Bluetooth-enabled device like a smartphone or tablet. This is a perfect project for those looking to get into IoT (Internet of Things) or robotics, combining the ease of Arduino programming with the convenience of wireless control.
Before diving into the code and setup, let’s gather everything you’ll need to get started:
Arduino Board (e.g., Arduino Uno)
Bluetooth Module (HC-05 or HC-06)
Servo Motor (e.g., SG90 or MG90S)
Smartphone or Bluetooth-enabled device
Power Supply (5V or 9V, depending on your setup)
Arduino IDE for programming
Once you have everything set up, let’s go through the basic principles of the project.
How Bluetooth and Arduino Communicate
Bluetooth modules like the HC-05 or HC-06 are commonly used to add wireless communication capabilities to Arduino projects. These modules use serial communication (TX/RX pins) to send and receive data from the Arduino. In our case, we’ll send commands from the smartphone app to the Arduino, which will then control the position of the servo motor.
Step 1: Connecting the Bluetooth Module to Arduino
The first step in setting up the system is connecting the Bluetooth module to the Arduino. Here’s the wiring setup:
HC-05/HC-06 Module to Arduino:
TX → RX (pin 0 on Arduino)
RX → TX (pin 1 on Arduino)
Ensure that you connect the Bluetooth module correctly, as a mistake here could cause communication issues. The RX and TX pins must be connected to the correct counterparts on the Arduino.
Step 2: Setting Up the Servo Motor
Next, let’s connect the servo motor. Servo motors have three wires: Power (VCC), Ground (GND), and Signal (PWM). Connect the following:
VCC → 5V on Arduino (or an external 5V power source if required)
PWM (Signal) → Pin 9 (or any other digital pin) on Arduino
Now that we’ve made the necessary physical connections, it’s time to write the code to make everything work!
Step 3: Arduino Code to Control the Servo Motor via Bluetooth
Let’s break down the core parts of the code. We’ll be using the Servo library to control the servo motor’s angle, and we’ll be reading serial data (commands sent via Bluetooth) to adjust the servo’s position.
#include // Include the Servo library
Servo myservo; // Create a servo object to control the servo
int bluetoothData = 0; // Variable to store Bluetooth data
Serial.begin(9600); // Start the serial communication
myservo.attach(9); // Attach the servo to pin 9
if (Serial.available() > 0) {
bluetoothData = Serial.read(); // Read the data from the Bluetooth module
// Map the Bluetooth data to a valid servo angle (0 to 180 degrees)
int servoAngle = map(bluetoothData, 0, 255, 0, 180);
myservo.write(servoAngle); // Set the servo to the mapped angle
delay(15); // Wait for the servo to reach the position
The Servo library simplifies controlling the servo motor.
We start by setting up the serial communication and initializing the servo on pin 9.
In the loop(), we check if there’s any data available from the Bluetooth module. When data is available, we read it using Serial.read().
We then map the data (which ranges from 0 to 255) to a servo angle (0 to 180 degrees).
Finally, the servo is set to the mapped angle using myservo.write().
At this stage, the Arduino is ready to receive Bluetooth commands and adjust the servo’s position based on the data received.
Making the Bluetooth Control Work on Your Smartphone
Now that we have the hardware and code set up, it’s time to make the Bluetooth communication work from your smartphone or tablet.
Step 4: Installing a Bluetooth Control App
There are several apps available for both Android and iOS that allow you to send Bluetooth data to the Arduino. One of the most popular and simple options is the Arduino Bluetooth Controller app, available on the Google Play Store. Alternatively, you can use Bluetooth Terminal or any app that allows you to send raw serial data over Bluetooth.
After installing the app, follow these steps:
Pair the Bluetooth Module: Open the Bluetooth settings on your smartphone and pair it with the HC-05 or HC-06 module. The default PIN for HC-05 is usually 1234 or 0000.
Connect the App to Bluetooth: Open the app and connect it to the paired Bluetooth device (HC-05/HC-06).
Send Data to Arduino: The app will provide an interface to send data. You can either use buttons, sliders, or a simple text input to send data. In our case, we’ll be sending values ranging from 0 to 255, corresponding to the servo angle.
Step 5: Testing the System
With the hardware, code, and app ready, it’s time to test the system. When you open the Bluetooth controller app and connect it to the HC-05 module, you should be able to send values (0–255) to the Arduino. The servo motor will move according to the value sent, adjusting its position from 0° to 180°.
No connection between Bluetooth and Arduino: Ensure the HC-05 module is properly paired with your smartphone. Double-check the wiring and serial communication settings.
Servo not moving: If the servo is not responding, check the power supply. Make sure the Arduino is getting enough power, and verify the servo is properly connected to the PWM pin.
Inconsistent movement: If the servo jerks or moves erratically, try adjusting the delay or mapping function in the code. Also, ensure there’s minimal interference in the Bluetooth communication.
Controlling a servo motor with Bluetooth and Arduino is an exciting and rewarding project. It allows you to experiment with wireless communication and get hands-on experience with robotics and IoT. Whether you’re building a robot arm, a camera mount, or just exploring the world of electronics, this setup will provide a solid foundation for more complex projects.
By following the simple steps outlined in this guide, you can easily get your servo motor up and running with Bluetooth control. The best part is that you can further modify the system—adding multiple servos, integrating sensors, or building more advanced projects with ease.
Start experimenting today, and who knows what cool devices you can create with your newfound skills in Bluetooth control and Arduino programming!
Leveraging innovations in modular drive technology, Kpower integrates high-performance motors, precision reducers, and multi-protocol control systems to provide efficient and customized smart drive system solutions.
Update:2025-10-15
Contact Kpower's product specialist to recommend suitable motor or gearbox for your product.