Bluetooth controlled stepper Motor – What should I make?

Just sharing how to control a bipolar stepper motor with arduino via bluetooth. below is a video demonstrating it and I also included the code in this blog post.

Now I just need to figure out what I am going to do with this thing.


Video



List of Items used


Short Body Nema 17 Bipolar Step Motor 3.5V 1A 18.4oz.in/13Ncm DIY CNC

Arduino Uno R3 Microcontroller A000066

HC-06 Bluetooth Serial Pass-Through Module Wireless Serial Communication Compatible With Arduino by Atomic Market

Adafruit TB6612 1.2A DC/Stepper Motor Driver Breakout Board


Code


#include

// change this to the number of steps on your motor
#define STEPS 200
// define AIN and BIN
Stepper stepper(STEPS, 4, 5, 6, 7);
//declare receiving varible
int value_bluetooth = 0;

void setup()

//set band width and stepper speed (30-120)
{
Serial.begin(9600);
Serial.println(“Stepper test!”);
stepper.setSpeed(60);
}

void loop()
{
if(Serial.available() > 0){
value_bluetooth = Serial.read();
}

{
if (value_bluetooth== ‘0’ ) {
Serial.println(“stop”);
stepper.step(0);
delay(500);
}

else if (value_bluetooth== ‘1’ ) {
Serial.println(“forward”);
stepper.step(STEPS);
}

else if (value_bluetooth== ‘2’ ){
Serial.println(“back”);
stepper.step(-STEPS);
}

}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s