Buetooth based stepper motor controller by arduino
Buetooth based stepper motor controller by arduino
The Stepper motor used here is a rusty old EPOCH (5 wires) stepper motor, which is a unipolar stepper.
Requiredments :
- Bluetooth Module ( for example : HC05 or HC06 )
- Jumper Cables
Checkout the video to know how the app control stepper motor
Source code for controlling stepper motor from android app:
-------------------------------------------------------------------------------------------------------------------------------
#include <AccelStepper.h>
AccelStepper stepper(AccelStepper::FULL2WIRE, 8, 9);
int spd = 1000; // The current speed in steps/second
int sign = 1; // Either 1, 0 or -1
void setup()
{
Serial.begin(9600);
stepper.setMaxSpeed(1000);
stepper.setSpeed(1000);
}
void loop()
{
char c;
if(Serial.available()) {
c = Serial.read();
if (c == 'f') { // forward
sign = 1;
}
if (c == 'r') { // reverse
sign = -1;
}
if (c == 's') { // stop
sign = 0;
}
if (c == '1') { // super slow
spd = 10;
}
if (c == '2') { // slow
spd = 100;
}
if (c == '3') { // medium
spd = 300;
}
if (c == '4') { // Fast
spd = 500;
}
if (c == '5') { // medium
spd = 700;
}
if (c == '6') { // medium
spd = 1000;
}
stepper.setSpeed(sign * spd);
}
stepper.runSpeed();
}
------------------------------------------------------------------------------------------------------------------------------
#include <AccelStepper.h>
AccelStepper stepper(AccelStepper::FULL2WIRE, 8, 9);
int spd = 1000; // The current speed in steps/second
int sign = 1; // Either 1, 0 or -1
void setup()
{
Serial.begin(9600);
stepper.setMaxSpeed(1000);
stepper.setSpeed(1000);
}
void loop()
{
char c;
if(Serial.available()) {
c = Serial.read();
if (c == 'f') { // forward
sign = 1;
}
if (c == 'r') { // reverse
sign = -1;
}
if (c == 's') { // stop
sign = 0;
}
if (c == '1') { // super slow
spd = 10;
}
if (c == '2') { // slow
spd = 100;
}
if (c == '3') { // medium
spd = 300;
}
if (c == '4') { // Fast
spd = 500;
}
if (c == '5') { // medium
spd = 700;
}
if (c == '6') { // medium
spd = 1000;
}
stepper.setSpeed(sign * spd);
}
stepper.runSpeed();
}
------------------------------------------------------------------------------------------------------------------------------
Comments
Post a Comment