Controle de velocidade e direção do motor de passo usando Arduino e módulo Bluetooth HC-06 por meio de um aplicativo Android

Stepper motor speed and direction control using Arduino and HC-06 Bluetooth module via an Android application

This is a simple tutorial on how to control stepper motor speed and direction using arduino uno and hc-06 bluetooth module via an android phone app. The motor I'm using is a unidirectional stepper motor. There are two types of stepper motors unidirectional and bidirectional. Unidirectional has four phases and bidirectional has 6 phases. The phases must be controlled properly, otherwise the desired output cannot be obtained. Before proceeding, I assume you are aware of the engine's steepest phases and know how to control them effectively for maximum output.

Arduino stepper motor Bluetooth control project – Working principle

The user pairs their Android phone with the hc-06 bluetooth module. After pairing, the user can start the motor, can move the shaft clockwise or counterclockwise, can change the rotational speed of the motor, can stop the motor with the commands that are embedded next to the code. The commands can be changed according to the user's needs. We will get to the code part later in the tutorial.

Arduino Stepper Motor Control Circuit

The circuit diagram of the project is given below. The stepper motor I'm using runs on 12V DC. The stepper motor coils draw about 80 mA to 250 mA, so we don't drive the steeper motor directly from the Arduino pins. We need some driver for this purpose and ULN2003, a darling matrix IC, is a good option. The ULN2003 is capable of supplying 500 mA of current at 50 V, it can easily supply 25 0 mA of current at 12 V.

The step coils are controlled through digital pins 2,3,4 and 5 of the Arduino. The pins are connected directly to the ULN2003 inputs. The corresponding outputs of the ULN2003 supply power to the motor coils. The Arduino is powered by an external 12V adopter and the uln2003 is powered by the same adopter. Hc06 is powered by Arduino's 3.3V power output.
Note: Arduino ground must be grounded with ULN2003 ground. Both ICs must have the same potential to become functional. If not grounded correctly, the circuit floats and the output is unpredictable.

Stepper motor speed and direction control using Arduino and HC-06 Bluetooth module via an Android application

Stepper motor speed and direction control using Arduino and HC-06 Bluetooth module via an Android application

Level Shifters Requirement

Arduino talks to hc06 bluetooth module in serial communication protocol. The baud rate for serial communication can be changed. I'm working on the default baud rate which is 9600 bps. The hc06 Bluetooth module operates on 3.3V and can be powered by the 3.3V source output of the Arduino Uno. Since the hc06 bluetooth works at 3.3v, it outputs the data in the form of a TTL signal rated at 3.3v. While the Arduino Uno operates at 5 V and its pins output data in the form of a TTL signal rated at 5 volts. To balance the TTL level voltage. Voltage level sieves are inserted between the pins. The Arduino TX is transmitting a 5V signal which is changed to 3.3V by just a simple voltage divider circuit. The hc06 TX is transmitting a 3.3V signal whose level changes to 5V.

Commands to operate and control the stepper motor via Bluetooth

Sending the following commands from the Android app after paired with the hc06 Bluetooth ule fashion will make the arduino enjoy actions in the stepper motor.

is or S = Starts and stops the stepper motor. The first s starts the engine and the next stops it.
f or F = Rotates the stepper motor clockwise.
b or B = Rotates the stepper motor counterclockwise.

Speed ​​rotation for stepper motor built into the code

0 = ————————————————– Rotation speed=1000;
1 = —————— Rotation speed =900;
2 = —————— Rotation speed =800;
3 = —————— Rotation speed =700;
4 = —————— Rotation speed =500;
5 = —————— Rotation speed =400;
6 = —————— Rotation speed =300;
7 = —————— Rotation speed =200;
8 = —————— Rotation speed =100;
9 = —————— Rotation speed =50;
The Android app I used can be found HERE . It's great and works efficiently at all baud rates. I've checked the pairing and engine operation at all gear ratios and everything works fine.

The Move Backward function rotates the motor counterclockwise. The Engine Start function turns the engine clockwise. The user can change the commands according to their needs. The user can also enter new rotation speeds.
More embedded microcontroller projects involving stepper motors are present in the tutorials section. Each project contains free source code and circuit diagram of the project. In each design, the speed and direction of the stepper motor are controlled using microcontrollers. Visit the tutorials below.

Stepper motor control via WiFi with nodemcu

Stepper motor with 32-bit STM32F103 microcontroller

Stepper motor controlled with 8051 microcontrollers(89c51, 89c52)

Download the project code written in Arduino IDE 1.6. The code is free and open source. Please give us your feedback on the project.

Watch the project video here.

Arduino project files code

Back to the blog

Leave a comment

Comments need to be approved before publication.