ICStation Team
Published

28BYJ-48 Stepper Motor Control System Based On Arduino With

It is widely used on ATM machine, inkjet printer,cutting plotter, fax machine,spraying equipment, medical instruments and equipments etc.

BeginnerFull instructions provided3,564
28BYJ-48 Stepper Motor Control System Based On Arduino With

Things used in this project

Hardware components

ICStation UNO
ICStation UNO
×1
1602A HD44780 Character LCD Display Module
×1
5V 4 Phase 5 Line 28BYJ-48 5VDC Stepper Motor
×1
50K Ohm B50K Knurled Shaft Linear Rotary Taper Potentiometer
×1
ULN2003AN DIP-16 TI Darlington Transistor Array
×1
Trim Pot Resistor Potentiometer
×1
830 Point Solderless PCB Bread Board MB-102 Test DIY
×1
12X12X5mm Tact Switches 4 Legs
×1
Bread Board Jump Line Jumper Wire
×1
Dupont 20cm Color Cable Line
×1
+5V DC power supply
×1

Story

Read more

Schematics

1.jpg

Code

Stepper Motor Code

C/C++
#include <Stepper.h>
#include <LiquidCrystal.h>

int Iint1=0;
int Iint2=1;
int anjian1=2;
int anjian2=3;
int motorSpeed;
LiquidCrystal lcd(9,8,7,6,5,4);

const int stepsPerRevolution =200;

// 	Here set the stepper motor rotation step how much is a circle
int dim=stepsPerRevolution;

//	Set the step motor number and pin
Stepper myStepper(stepsPerRevolution, 10,11,12,13);  

void setup()
{  
   lcd.begin(16, 2);
   lcd.print("speed:");
   
   lcd.setCursor(10,0);
   lcd.print("n/min");
   
   lcd.setCursor(0, 1);
   lcd.print("Direction:");
   
   // 	Set the motor speed of 60 steps per minute
   myStepper.setSpeed(60);     
   
   pinMode(anjian1,INPUT_PULLUP);
   pinMode(anjian2,INPUT_PULLUP);
   attachInterrupt(Iint1,counterclockwise,FALLING);
   attachInterrupt(Iint2,clockwise,FALLING);
   Serial.begin(9600);
}

void loop() 
 { 
   
   myStepper.step(dim);
   void Direction();
   //	 Read the sensor values:
   int sensorReading = analogRead(A0);
   // 	Map it to a range of 0-150:
   int motorSpeed = map(sensorReading, 0, 1023, 0, 150);
   // 	Set the motor speed:
   if (motorSpeed > 0) 
    {
        myStepper.setSpeed(motorSpeed);
        lcd.setCursor(6,0);
        lcd.print(float(float(motorSpeed)/float(200)));
    } 
  }
   
 void clockwise()
  { 
     //   clockwise rotation
     dim=stepsPerRevolution;
     lcd.setCursor(10, 1);
     lcd.print(">>>>>>");
  }
    

  void counterclockwise()
  {  
     //	anti-clockwise
     dim=-stepsPerRevolution;
     lcd.setCursor(10, 1);
     lcd.print("<<<<<<");
   }

Credits

ICStation Team
27 projects • 46 followers
ICStation.com is a leading company specializes in all kinds of IC products, such as electronic devices and components, development modules, development boards,

Comments