This is a simple tutorial on how to control speed and direction of stepper motor using arduino uno and bluetooth module hc-06 through an android phone app. The motor which i am using is Uni directional stepper motor. Their are two types of stepper motors unidirectional and bidirectional. Uni directional has four phases and bidirectional has 6 phases. Phases must be controlled properly other wise desired output can not be obtained. Before going further i assume that you are aware of the steeper motor phases and know how to control them effectively in order to get the maximum output.
Arduino stepper motor Bluetooth control project – Working principle
The user pairs its android phone with the hc-06 bluetooth module. After paring user can start the motor, can move the shaft in either direction clock or anti clock wise, can change the speed of motor rotation, can stop the motor with the commands that are embedded in side the code. The commands can be changed according to the user need. We will come to the code portion later in the tutorial.
Arduino stepper motor control circuit
Circuit diagram of the project is given below. The stepper motor which i am using works on 12 v DC. Stepper motor coils consumes about 80 mA to 250 mA, so we an not drive the steeper motor directly from arduino pins. We need some driver for this purpose and ULN2003 a darling-ton array ic is a good fit-in. ULN2003 is capable of sourcing 500 mA of current at 50 v, it can easily source 25 0mA current at 12 v.
Stepper coils are controlled through arduino digital pins 2,3,4 and 5. The pins are directly connected to inputs of uln2003. The corresponding outputs of the uln2003 is supplying power to motor coils. Arduino is powered through external 12v adopter and uln2003 is powered through the same adopter. Hc06 is powered through the 3.3v supply output of arduino.
Note: The ground of the arduino must be grounded with ULN2003 ground. Both the ic’s must be at same potential to become functional. If not grounded properly the circuit floats and the output is unpredictable.
Stepper coils are controlled through arduino digital pins 2,3,4 and 5. The pins are directly connected to inputs of uln2003. The corresponding outputs of the uln2003 is supplying power to motor coils. Arduino is powered through external 12v adopter and uln2003 is powered through the same adopter. Hc06 is powered through the 3.3v supply output of arduino.
Note: The ground of the arduino must be grounded with ULN2003 ground. Both the ic’s must be at same potential to become functional. If not grounded properly the circuit floats and the output is unpredictable.
Level shifters requirement
Arduino talks with hc06 bluetooth module on serial communication protocol. The baud rate for serial communication can be changed. I am working on default baud rate which is 9600 bps. Bluetooth module hc06 works on 3.3 v and can be powered from the 3.3 v source output of arduino uno. Since the hc06 bluetooth works on 3.3 v it outputs the data in the form of TTL signal rated at 3.3 v. Where as arduino uno operates on 5 v and its pins output data in the form of TTL signal rated at 5 volt. To balance the TTL level voltage. Voltage level sifters are inserted between the pins. Arduino TX is transmitting a 5 v signal which is shifted to 3.3 v by just a simple voltage divider circuit. The hc06 TX is transmitting a 3.3 v signal which is level shifted to 5 v.
Commands to run and control stepper motor from Bluetooth
Sending following commands from android app after it is paired with the hc06 Bluetooth module will make arduino to perform functions on stepper motor.
s or S = Starts and stops the stepper motor. First s starts motor and the coming next stops it.
f or F = Rotates stepper motor in clockwise direction.
b or B = Rotates stepper motor in anticlockwise direction.
Speed rotation for stepper motor embedded in 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;
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;
Android app which i used can be found HERE. Its great and works efficiently on all the baud rates. I checked the pairing and working of motor on all baud rates and all works fine.
The function Move_Backward() rotates the motor in anticlockwise direction. The function StartMotor() rotates the motor in clockwise direction. User can change the commands according to his need. User can also insert the new rotation speeds.
The function Move_Backward() rotates the motor in anticlockwise direction. The function StartMotor() rotates the motor in clockwise direction. User can change the commands according to his need. User can also insert the new rotation speeds.
More embedded microcontroller projects involving stepper motors in them are present in tutorials section. Each project contains free source code and circuit diagram of the project. In each project stepper motor speed and direction is controlled using microcontrollers. Visit the tutorials below.
Download the project code written in arduino ide 1.6. Code is free and opensource. Please give us your feed back on the project.
Watch the Project Video Here..
You may also like:
What are different types of industrial robots?
What types of motors are used in electric vehicles?
What is Wireless Electric Vehicle Charging System (WEVCS)?
What is the role of embedded software in electric vehicles?
What are the components of robotic arms and industrial robots?
What drone parts you need to build a quadcopter?
Filed Under: Arduino, Electronic Projects, Microcontroller Projects
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.