Saturday, May 23, 2015

Control stepper Motor from android app




Stepper Motor controlled from Android, the android app created using MIT app inventor. This app will only work for Easydriver for stepper motor, other stepper control will not work with this app.

Checkout the video to know how the app control stepper motor, this is a very simple stepper control application which you can make and understand how to control a stepper motor from android.


Arduino 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();
}

------------------------------------------------------------------------------------------------------------------------------  

Android app link click here

-------------------------------------------------------------------------------------------------------------------------------


MIT app inventor blocks:







6 comments:

  1. Hi I have built this and it works quite well. There is some hesitation in the motor at slow speed which can be a problem. Will you be including a link to the source code as it would be nice to have a wider gap between direction and speed buttons?
    Many thanks for the app I use it to focus my telescope.

    ReplyDelete
  2. accelstepper.h
    so we have to add a library for it in arduino uno?

    ReplyDelete
  3. Great program. Thanks for letting me know of MIT app.

    ReplyDelete
  4. we make is work, but i want make with limit switch..
    how make code ??

    ReplyDelete
  5. We tried to repicate it but we are having some trouble as it is not controlling via bluetooth

    ReplyDelete