Driving 28BYJ-48 4-phase Step Motor with Arduino UNO:


Required Components:
1.
28BYJ-48 4 phase Step Motor with Driver Board
2. Arduino UNO

 

Plug the stepper motor to the driver board with the cable provided.

IN 1,2,3 & 4 of the driver board to the Arduino UNO pin 11, 10, 9 & 8 respectively.

Also, GND and +V of the driver board to the Arduino UNO GND and +5V.

 

Use the following Arduino code, (not using any library):


#define Steps_Per _Rev  512

Void setup(){
Pinmode (11, OUTPUT);
Pinmode (10, OUTPUT);
Pinmode (9, OUTPUT);
Pinmode (8, OUTPUT);
}
 
Void write(int a, int b, int c, int d){
digitalWrite(11, a);
digitalWrite(10,b);
digitalWrite(9,c);
digitalWrite(8,d);
}

Void Onestep_forward(){
  write(1,0,0,0);
  delay(5);
  write(1,1,0,0);
  delay(5);
  write(0,1,0,0);
  delay(5);
  write(0,1,1,0);
  delay(5);
  write(0,0,1,0);
  delay(5);
  write(0,0,1,1);
  delay(5);
  write(0,0,0,1);
  delay(5);
  write(1,0,0,1);
  delay(5);
}

Void Onestep_reverse (){
  write(1,0,0,1);
  delay(5);
  write(0,0,0,1);
  delay(5);
  write(0,0,1,1);
  delay(5);
  write(0,0,1,0);
  delay(5);
  write(0,1,1,0);
  delay(5);
  write(0,1,0,0);
  delay(5);
  write(1,1,0,0);
  delay(5);
  write(1,0,0,0);
  delay(5);
}


void loop(){
int i;
i=0;
while(i<Steps_Per_Rev){
onestep_forward();
i++;

i=0;
while(i<Steps_Per_Rev){
onestep_reverse();
i++;

}



0Comments

For Comment you need to Login