Arduino Uno R3+ Android+Adafruit Motor Shield v2 + Bluetooth Transceiver (HC-06) + Stepper motor (FL
Arduino Uno R3+ Adafruit Motor Shield v2 + Bluetooth Transceiver (HC-06) + Stepper motor (FL42STH47-0806MA)
STEP 1:
Setting up the HC-06. All you need to know is the pin configuration. The HC-06 has 6 pins: wakeup, VCC, GND, TXD, RXD and State. Right now I will only deal with 4 pins, which are VCC, GND, TXD and RXD.
Here is how you should connect the Bluetooth module to your Arduino. HC-06>>>Arduino
VCC>>>>3.3v
GND>>>>GND
TXD>>>>RXD
RXD>>>>TXD
The HC-06 acts as a serial port through which you can send and receive data. So using a serial terminal or a Bluetooth customized application on your computer or phone, you can control and monitor your project. I used Tera Term as the serial terminal.
Before, uploading the code to the Arduino, disconnect the HC-06 module, since it shares the tx/rx pins and will interfere with the upload. Connect it back once the code has been uploaded successfully.
STEP 2:
This code enables you to send a string to the Arduino via Bluetooth and get an echo back on your serial monitor.
This code allows you to make the stepper motor rotates forward and backward for 4 revolutions by sending a command “f” or “b” to the Arduino via Bluetooth.
/*
This is a test sketch for the Adafruit assembled Motor Shield for Arduino v2
It won't work with v1.x motor shields! Only for the v2's with built in PWM
control
*/
#include <Wire.h>
#include <Adafruit_MotorShield.h>
char blueToothVal; //value sent over via bluetooth
Adafruit_MotorShield AFMS = Adafruit_MotorShield(); // Create the motor shield object with the default I2C address
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61);
// Connect a stepper motor with 400 steps per revolution (0.9degree)
// to motor port #2 (M3 and M4)
Adafruit_StepperMotor *myMotor = AFMS.getStepper(400, 2); // Connect a stepper motor with 400 steps per revolution (0.9degree)
// to motor port #2 (M3 and M4)
void setup()
{
Serial.begin(9600); // set up Serial library at 9600 bps
AFMS.begin(); // create with the default frequency 1.6KHz
//AFMS.begin(1000);
// OR with a different frequency, say 1KHz
myMotor->setSpeed(100); // 100 rpm
}
void loop()
{
if(Serial.available()) //if there is data being recieved
{
blueToothVal=Serial.read(); //read it
}
if (blueToothVal=='f') //if value from bluetooth serial is f
{
myMotor->step(1600, FORWARD, DOUBLE); //stepper rotates forward for 4 revolutions
}
else if (blueToothVal=='b') //if value from bluetooth serial is b
{
myMotor->step(1600, BACKWARD, DOUBLE); //stepper rotates backward for 4 revolutions
}
}
STEP 3:
Pair the HC-06 with your computer or any other Bluetooth device you have as shown in the video
https://www.youtube.com/watch?v=72T7PqFT010
NB: In the video, you should connect your serial terminal program (teraterm) to the INCOMING com port. This is not right. The correct way should be connecting your serial terminal program to the OUTGOING com port.
STEP 4:
Once the module is paired. Open Teraterm, or any other serial terminal program you have. Select the serial port that corresponds to the HC-06 (I have explained how to identify that port in the video).
Once you successfully connect to the HC-06 serial port you will be able to send strings to your Arduino and get an echo back. If you have uploaded the code, you will be able to control the stepper motor by sending “f” and “b” respectively.
STEP 5:
There are many applications of the HC-06. You can also use your android phone or ios phone to control the stepper. Control version are as following:
References:
http://www.instructables.com/id/Add-bluetooth-to-your-Arduino-project-ArduinoHC-06/
http://motor-fulling.com/1-5-42mm-hybrid-stepper-motor.html/122689
https://learn.adafruit.com/bluetooth-motorized-camera-slider/usage