28BYJ-48 Stepper Motor control Android app

Hello world! Today i made a simple app to turn one 28BYJ-48 stepper motor on and off, it just rotates to one direction. I will make a app to control the curtains of your house next, with the same motor. If you want the source code of the android app just contact me contact@arduinosensors.nl
Get the APP on GOOGLE PLAY!

28byj-48

Schematic:
28byj-48

Just wire it up like the Schematic and it should work after uploading the code.
Make sure you disconnect the HC-06 when uploading the code. Other wise the arduino becomes confused.

Parts list:
Arduino uno, I used the RobotDyn Uno which has 7 analog pins instead of 5.
HC-06 Bluetooth module.
28BYJ-48 Stepper motor With the ULN2003 driver board
Jumper wire set. MM/FF/MF
Android phone and our APP.

Code:

char inData[20]; // Allocate some space for the string
char inChar=-1; // Where to store the character read
byte index = 0; // Index into array; where to store the character
boolean running = false;



/*-----( Import needed libraries )-----*/
#include <Stepper.h>

/*-----( Declare Constants, Pin Numbers )-----*/
#define STEPS  100   //Number of steps per revolution


/*-----( Declare objects )-----*/
/* create an instance of the stepper class, specifying
 the number of steps of the motor and the pins it's
 attached to. The pin connections need to be 4 pins connected
 to Motor Driver In1, In2, In3, In4  and then the pins entered
 here in the sequence 1-3-2-4 for proper sequencing*/

Stepper small_stepper(STEPS, 8, 10, 9, 11);

int  Steps2Take = 2038;

void setup(){   
    Serial.begin(9600);
    Serial.print("RDY!");

}

char Comp(char* This) {
    while (Serial.available() > 0) // Don't read unless
                                   // there you know there is data
    {
        if(index < 19) // One less than the size of the array
        {
            inChar = Serial.read(); // Read a character
            inData[index] = inChar; // Store it
            index++; // Increment where to write next
            inData[index] = '\0'; // Null terminate the string
        }
    }
    //Serial.println(inData);

    if (strcmp(inData,This)  == 0) {
        for (int i=0;i<19;i++) {
            inData[i]=0;
        }
        index=0;
        return(0);
    }
    else {
        return(1);
    }
}

void loop (){
  
    
    if (Comp("motoron")==0) {
        Serial.write("Motor is on\n");
        running = true;
    }
    if (Comp("motoroff")==0) {
        Serial.write("Motor is off\n");
        running = false;
    }
    if (running == true){
      run();
    }
//    delay(250);
}

void run(){
  small_stepper.setSpeed(300);
  small_stepper.step(Steps2Take);
}
Danny van den Brande

http://www.arduinosensors.nl

Programmer, Game Designer, 3D Designer, Web Designer, Graphic Designer. Jup this website looks crappy.. :) But enjoy the projects! Everything you need is here.

Leave a Reply

Your email address will not be published. Required fields are marked *