Controle de velocidade do motor DC usando o aplicativo Android baseado em Bluetooth

DC Motor Speed ​​Control Using Bluetooth Based Android App

This project is a little different from the previous ones we covered about DC motor control. So far, the articles have included information on how to control the speed of a DC motor using:

  • Arduino
  • An 8051 microcontroller
  • An AVR/PIC/ARM microcontroller
  • A remote control
  • SMS
  • bluetooth

This time, we will cover DC motor speed control through an Android application. For this project, the application is installed on a smartphone that uses Bluetooth to send commands to the circuit, which controls the speed of the DC motor.

This Android app has an attractive, inviting, and easy-to-use graphical user interface (GUI). We'll use buttons, a slider, and a speedometer, making this project very different from the others we've covered.

But first, here's what you need...

Required Items

1. An Arduino NANO development board

2. A12-V DC Motor

3. One HC05 bluetooth module

4. A TIP122 NPN Darlington Transistor

5. A 330 ohm resistor
6. A 12V power supply/adapter

Now, let's build the circuit and then we'll cover how it works.

Circuit Diagram

This circuit is built using just three components: Arduino NANO, the HC05 Bluetooth module and a Darlington TIP122 transistor.

  • The HC05 has four interface pins: Vcc, GND, Tx and Rx. Here, the Vcc pin receives a 5V supply from the Arduino board and the GND pin is connected to the ground of the board. The Tx and Rx pins are connected to the Arduino pins D4 and D5 respectively.
  • PWM output pin D3 drives 12V DC motor using TIP122. It is connected to the base terminal of the TIP122 via the 330 ohm current limiting resistor.
  • The TIP122 is used to amplify the current, providing the necessary current to the motor. The DC motor is connected between the collector output and the 12 V supply. The emitter terminal of the TIP122 is connected to ground.

The circuit arrangement

Circuit operation
The circuit controls the speed of the 12V DC motor using the Android app on a smartphone. The app sends commands to start or stop the engine and to change the engine speed via the smartphone's Bluetooth.

These commands are received by the HC05 module, which passes them to the Arduino NANO through the Tx and Rx pins. According to the commands sent, the Arduino will turn the DC motor on or off, or vary its speed from minimum to maximum.

The Arduino generates a PWM signal on its D3 pin to start or stop the motor or to vary the motor speed. To stop the motor, the pulse width at pin D3 is 0 (0%). And to operate the engine at maximum speed, it is 255 (100%). So, as the Arduino changes the pulse width at its D3 pin, the motor speed changes from minimum to maximum – or vice versa.

The Arduino can also send a change in motor speed (0 to 100%) from the HC05 module to the smartphone app. The Android app will display this engine speed value on an analog dial (or quick dial).

The Android app
The Android app is built using the “Bluetooth Electronics” app, which is available for free on Google Play.

First, download and install the “Bluetooth Electronics” app on your Android phone and open it. It will ask if you want to “TURN ON” the device’s Bluetooth. Allow this to happen. Once the application launches, you will see some ready-made control panels that control Arduino-based projects.

Perhaps the most interesting feature of this app: it allows users to build a custom panel to control Arduino projects.

Let's build a custom panel to control the speed of the DC motor.

The panel consists of a green and red button to “ON” or “OFF” the mother. It also has a slider to vary the engine speed and a dial to view the engine speed.

See how to make the panel:

1. Select a green button. Then, go to the right corner of the screen and edit the button properties as follows:

Press Text: N
Launch text:

2. Choose the text size with a small or medium font and write “Engine ON”.

3. Select a red button and edit its properties as follows:

Press Text: F
Launch text:

4. Choose the text size with a small or medium font and write “Engine OFF”.

5. Select the largest slider from the slider options and edit its properties as follows:

Minimum value: 100
Maximum value: 255
Select “Submit on slider change”

The string starts with: *
String ends with: #

6. Go to indicator options and choose analog dial. Edit your properties like this:

Receive character: D
Minimum text: 0
Maximum text: 100
minimum value: 0
maximum value: 100
leave default all others

7. Write all other texts such as “min”, “max”, “engine speed”, “speed indicator” etc. as you wish.

And that's it! Your Android app is ready to control DC motor speed.

Running the project

1. Connect the circuit according to the schematic provided on the breadboard or general purpose PCB.

2. Provide 12V power supply to the circuit.

3. Initially, the engine is not moving and is in the stopped position. The HC05 module will begin flashing to indicate that it is searching for the device.

4. Launch the “Bluetooth Electronics” app on your smartphone, ensuring Bluetooth is “ON”.

5. Press the connect button to search for the HC05 module. When the device is found, select “HC05” and press connect. When doing this for the first time, you will have to enter the password “1234”.

6. Once the HC05 is connected, press done .

7. You can now run your dashboard.

8. On the dashboard, press the green button to start the engine or the red button to stop it.

9. While the engine is running, change the slider to vary the engine speed.

10. As the slider moves, the speed dial will indicate the motor speed (from 0 to 100%).

Software program:
This project works thanks to software downloaded onto the Arduino ATMega328 microcontroller. The program is written in C language using Arduino IDE software.

#include
SoftwareSerial bt_ser(4,5);
character c(6);
int i=0,speed_value=150,send_value;
bool fan_on_flag = false;
null configuration
{
Serial.begin(9600);
bt_ser.begin(9600);
analogWrite(3,0);
Serial.println(“DC motor speed control using Android app”);
}

empty loop
{
while(bt_ser.disponível)
{
if(bt_ser.available >0)
{
c(i) = bt_ser.read ;
Serial.print(c(i));
me++;
}
if(c(i-1)=='N')
{
analogWrite(3,speed_value);
fan_on_flag = true;
l=0;
}
if(c(i-1)=='F')
{
analogWrite(3,0);
fan_on_flag = false;
l=0;
}
if(c(i-1)=='#')
{
speed_value = (c(1)-48)*100+(c(2)-48)*10+(c(3)-48)*1;
send_value = map(speed_value,100,255,0,100);
if(fan_on_flag) analogWrite(3,speed_value);
Serial.print(speed_value);
Serial.print('\t');
Serial.println(send_value);
bt_ser.print(“*D”);
bt_ser.print(send_value);
bt_ser.print('*');
l=0;
}
}
}

Back to the blog

Leave a comment

Comments need to be approved before publication.