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.