#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit dula=P2^1; //段选
sbit wela=P2^0; //位选
uchar code tabledu[]={
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; //位码
uchar code tablewe[]={
0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}; //段码
uchar Data[8]; //存数位的段码
sbit d1=P1^0; //定义步进电机的端口
sbit d2=P1^1;
sbit d3=P1^2;
sbit d4=P1^3;
#define A {d1=1,d2=0,d3=0,d4=0;} //1-2相励磁法
#define B {d1=0,d2=1,d3=0,d4=0;}
#define C {d1=0,d2=0,d3=1,d4=0;}
#define D {d1=0,d2=0,d3=0,d4=1;}
#define AB {d1=1,d2=1,d3=0,d4=0;}
#define BC {d1=0,d2=1,d3=1,d4=0;}
#define CD {d1=0,d2=0,d3=1,d4=1;}
#define DA {d1=1,d2=0,d3=0,d4=1;}
#define OF {d1=0,d2=0,d3=0,d4=0;}
voi
步进电机减速转动,数码管显示转速
最新推荐文章于 2022-04-22 10:09:53 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)