Introduction: DC Motor Control With Bluetooth
The purpose of this proyect consist on control a DC motor with a Smartphone. The speedo of the DC motor will change. The communication between the DC motor and the Smartphone will be done using a Bluetooth module attached to an Arduino UNO module
Step 1: The Design of the Circuit
First, according to specifications (what we want to do) a sketch of the circuit will be developed. This first drawing of the circuit, can be also done using a circuit design programm. For this proyect, the circuit will be designed with a free to use design online software called 123D circuits. The needed materials are:
- Arduino UNO development board
- Bluetooth HC-05 module
- NPN Transistor, TIP 31C
- DC motor (5 Volts)
- Two source powers (4 AA battery case)
- fan blade
- Cables and connector for battery case
Step 2: Circuit Simulation
After the design of the circuit, a test will be performed in order to know if the designed circuit will properly work. In the past, was necesary to build the circuit in order to test it. Now it its possible to simulate a circuit in order to know with more precision, how will it works. The online free tool 123D circuits will be used for the simulation. The component in red is the Bluetooth module
Step 3: Bluetooth Module (HC-05)
A commonly used Bluetooth module is the HC-05. Since the communication between the PC and the Arduino UNO is serial, the wireless communication is achieved using a device (HC-05) that emulates the serial communication. Two pins from the Arduino are needed, by default are the pins 0 and 1 (RX ==> receive, TX ==> transmit). Also there is a library that can emulate the function of these 2 pins using other different pins. The HC-05 has 6 pins, for this proyect only four will be used, the pins STATE and EN will be disconected.
Step 4: Assembly of the Circuit
The picture shows all the needed componets. Two power sources will be needed, one for the Arduino UNO board and other for the componets outside the Arduino UNO board (Bluetooth module, transistor, DC motor), this two power sources must have a common earth (the two 0 Volts wires must be connected each other).
The control of the DC motor will be defined using number in the programm:
0 ==> off
1 ==> speed 1 (12.5%)
2 ==> speed 2 (25%)
3 ==> speed 3 (37.5%)
4 ==> speed 4 (50%)
5 ==> speed 5 (62.5%)
6 ==> speed 6 (75%)
7 ==> speed 7 (87.5%)
8 ==> speed 8 (100%)
Step 5: Smartphone Connection and Programm
In this step, will be posted the programm. The connection in the smartphone will be done using an app for Bluetooth connection with an Arduion board. Many apps are in Google Play. After installing the app, the connection between the HC-05 and the smartphone must be established. First the smartphone must search, find and connect with the HC-05. Then the installed app should be oppened and in this app, the connection with the HC-05 must be again established.
Here is the used programm with comments.
// The program is designed to perform the next tasks:
// 1. A Bluetooth module (HC-05) will be configured
// and attachet to an Arduino UNO module
// 2. A DC motor will be attached to one output of the Arduino board
// 3. The DC motor will be remotely controlled using a smartphone
// 4. Different speeds will be programmed
// Written by Alberto Morales San Juan
#include // serial communication library
SoftwareSerial ConfigurePorts (8, 9); // Port_8 ==> RX, Port_9 ==> TX
int ReceiveInfo; // for the received information
int MotorPort=11; // Port 13 for the dc motor
void setup()
{
ConfigurePorts.begin(9600); // Baud rate
ConfigurePorts.println("0=off, 1=speed 1, 2=speed 2 ...");
pinMode(MotorPort, OUTPUT);
}
void loop()
{
if(ConfigurePorts.available()>0)
{
ReceiveInfo=ConfigurePorts.read();
switch (ReceiveInfo)
{
case '0': // off
analogWrite(MotorPort,0);
ConfigurePorts.println("off");
break;
case '1': // speed 1
analogWrite(MotorPort,40);
ConfigurePorts.println("1");
break;
case '2': // speed 2
analogWrite(MotorPort,60);
ConfigurePorts.println("2");
break;
case '3': // speed 3
analogWrite(MotorPort,80);
ConfigurePorts.println("3");
break;
case '4': // speed 4
analogWrite(MotorPort,100);
ConfigurePorts.println("4");
break;
case '5': // speed 5
analogWrite(MotorPort,120);
ConfigurePorts.println("5");
break;
case '6': // speed 6
analogWrite(MotorPort,160);
ConfigurePorts.println("6");
break;
case '7': // speed 7
analogWrite(MotorPort,200);
ConfigurePorts.println("7");
break;
case '8': // speed 8
analogWrite(MotorPort,240);
ConfigurePorts.println("8");
break;
}
}
}
Step 6: Test
The proyect will be tested using the smartphone.
18 Comments
8 months ago on Step 6
what are the codes with arduino uno starter
5 years ago on Step 2
Will you please also send the .APK file you made in this project, it would be of great help.
5 years ago
you use #include the file you're wanting to attach isn't listed. Did I miss something?
Reply 5 years ago
Nm. Using the SoftwareSerial.h makes this code unnecessarily complicated. Additionally, pointing out that the pins 3, 5, 9-11 have PWM (i.e. are the only ones that can support this throttling) would seriously be advisable for those that are new to this.
However, this is a decent tutorial using an NPN transistor (I'm using an L293D, but that doesn't make much difference, as I've discovered).
6 years ago
I am trying to upload this arduino program onto the board, I am using the Arduino1.8.2 to do it, but the sketch won't verify for some reason. How were you able to upload this sketch as a software to the board?
6 years ago
what programm should we use to configure arduino
6 years ago
what would you need to do to make the motor go forward or reverse?
7 years ago
Where can I find Android program code?
Reply 7 years ago
The program code in in the tutorial, on step 5.
7 years ago
hii sir... i made the connections as per the instructions...and also programmed the arduino uno...i can connect the bluetooth to my android ...but i can't control the speed...
when i connect the circuit the motor starts working ... if i give instruction in mobile like 0 it gives result as off... but no change in speed of motor . help me to fix it..
7 years ago
is the code downloaded to the phone ? it didn't look like you were connected to a computer.
Reply 7 years ago
the code is not downloaded to the phone. There is a communication between the phone and the Arduino. The phone sends the instructions to the Arduino
7 years ago
Why don't you use the RX and TX on the arduino board??
Reply 7 years ago
Hello, the RX and TX pins can be used also. A second posibility is to use the software serial command to work with other pins
7 years ago
Why didnt you use a diode?
Reply 7 years ago
I used two independent Voltage source. One source for the electronics and the second one for the dc motor
7 years ago
which app did u use from playstore?
Reply 7 years ago
Hello,
I used the "Bluetooth Terminal" and the "ArduinoRC" apps. Theoretically all apps that are included in the search term "android bluetooth" should work.
Also remember to pair first your smartphone with the HC-05 module.
BR