Hardware selection : It is sold on a treasure , One drive board plus one 5V The small stepper motor is 10 Yuan , This suit is usually used for camera rotation, etc , Because the motor and drive plate are small , Small power , Prone to fever .

altogether 3 Kinds of programs , Decelerate , accelerate , Forward and reverse , What kind of choice do you need . ****************************************************
*** Decelerate : Wiring mode : IN1 ---- P00 IN2 ---- P01 IN3 ---- P02 IN4 ---- P03 + ---- +5V -
---- GND *********************/ #include<reg52.h> #define uchar unsigned char #
define uint unsigned int #define MotorData P0 // Stepper motor control interface definition uchar phasecw[4] ={
0x08,0x04,0x02,0x01};// Forward rotation Motor conduction phase sequence D-C-B-A uchar phaseccw[4]={0x01,0x02,0x04,0x08}
;// reversal Motor conduction phase sequence A-B-C-D uchar speed; //ms Delay Functions void Delay_xms(uint x) { uint i,j;
for(i=0;i<x;i++) for(j=0;j<112;j++); } // Clockwise rotation void MotorCW(void) { uchar i; for
(i=0;i<4;i++) { MotorData=phasecw[i]; Delay_xms(speed);// Speed regulation } } // Stop turning void
MotorStop(void) { MotorData=0x00; } // Main function void main(void) { uint i; Delay_xms(50
);// Wait for the system to stabilize speed=4; while(1) { for(i=0;i<10;i++) { MotorCW(); // Clockwise rotation } speed++;
// Decelerate if(speed>25) { speed=4; // Restart deceleration movement MotorStop(); Delay_xms(500); } } } *****
************************************************** accelerate : Wiring mode : IN1 ---- P00 IN2 --
-- P01 IN3 ---- P02 IN4 ---- P03 + ---- +5V - ---- GND *********************/ #
include<reg52.h> #define uchar unsigned char #define uint unsigned int #define
MotorData P0// Stepper motor control interface definition uchar phasecw[4] ={0x08,0x04,0x02,0x01};// Forward rotation Motor conduction phase sequence
D-C-B-A uchar phaseccw[4]={0x01,0x02,0x04,0x08};// reversal Motor conduction phase sequence A-B-C-D uchar speed;
//ms Delay Functions void Delay_xms(uint x) { uint i,j; for(i=0;i<x;i++) for(j=0;j<112;j++);
} // Clockwise rotation void MotorCW(void) { uchar i; for(i=0;i<4;i++) { MotorData=phasecw[i];
Delay_xms(speed);// Speed regulation } } // Stop turning void MotorStop(void) { MotorData=0x00; }
// Main function void main(void) { uint i; Delay_xms(50);// Wait for the system to stabilize speed=25; while(1) { for(
i=0;i<10;i++) { MotorCW(); // Clockwise rotation } speed--; // Decelerate if(speed<4) { speed=25;
// Restart deceleration movement MotorStop(); Delay_xms(500); } } } **********************************
********************* Forward and reverse : Wiring mode : IN1 ---- P00 IN2 ---- P01 IN3 ---- P02 IN4 ----
P03+ ---- +5V - ---- GND *********************/ #include<reg52.h> #define
uchar unsigned char #define uint unsigned int #define MotorData P0 // Stepper motor control interface definition
uchar phasecw[4] ={0x08,0x04,0x02,0x01};// Forward rotation Motor conduction phase sequence D-C-B-A uchar phaseccw[4]={
0x01,0x02,0x04,0x08};// reversal Motor conduction phase sequence A-B-C-D //ms Delay Functions void Delay_xms(uint x) { uint
i,j; for(i=0;i<x;i++) for(j=0;j<112;j++); } // Clockwise rotation void MotorCW(void) { uchar i
; for(i=0;i<4;i++) { MotorData=phasecw[i]; Delay_xms(4);// Speed regulation } } // turn anticlockwise void
MotorCCW(void) { uchar i; for(i=0;i<4;i++) { MotorData=phaseccw[i]; Delay_xms(4)
;// Speed regulation } } // Stop turning void MotorStop(void) { MotorData=0x00; } // Main function void main(void
) { uint i; Delay_xms(50);// Wait for the system to stabilize while(1) { for(i=0;i<500;i++) { MotorCW();
// Clockwise rotation } MotorStop(); // Stop turning Delay_xms(500); for(i=0;i<500;i++) { MotorCCW();
// turn anticlockwise } MotorStop(); // Stop turning Delay_xms(500); } }
Schematic diagram of drive board :

Technology