資源簡介
用51單片機控制A4988驅(qū)動芯片驅(qū)動步進電機及線激光

代碼片段和文件信息
#include?
#define?uchar?unsigned?char?
#define?uint?unsigned?int
sbit?ENABLE=P1^4;?//使能
sbit?STEP=P1^3;???//步進數(shù)
sbit?Dir=P1^2;????//控制正反轉(zhuǎn)
sbit?Laser1=P3^4;
sbit?Laser2=P3^5;
uint?x;unsigned?char?flagai;
void?init()
{
TMOD=0x20;
TH1=0xfd;
TL1=0xfd;
TR1=1;
REN=1;
SM0=0;
SM1=1;
EA=1;
ES=1;
Laser1=0;
Laser2=0;
}
void?delayms(uint?xms)
{
uint?ij;
for(i=xms;i>0;i--)
for(j=110;j>0;j--);
}
void?main()
{
init();
while(1)
{
if(flag==1)
{
ES=0;
if(a==‘1‘)
{
???? ENABLE=0;
Dir=0;
for(x=0;x<200;x++)
{
STEP=1;
delayms(1);
STEP=0;
delayms(1);
}
delayms(1000);
Dir=1;
for(x=0;x<200;x++)
{
STEP=1;
delayms(1);
STEP=0;
delayms(1);
}
delayms(1000);
}
if(a==‘2‘)
{
???Laser1=1;
Laser2=1;
}
if(a==‘3‘)
{
???Laser1=0;
Laser2=0;
}
SBUF=a;
???while(!TI);
?? TI=0;
ES=1;
flag=0;
}
}
}
void?ser()?interrupt?4
{
RI=0;
a=SBUF;
flag=1;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1942??2017-06-15?17:00??Laser_Motor\Laser_Motor
?????文件???????1125??2017-06-15?23:14??Laser_Motor\Laser_Motor.c
?????文件????????681??2017-06-15?17:00??Laser_Motor\Laser_Motor.hex
?????文件?????????54??2017-06-15?17:00??Laser_Motor\Laser_Motor.lnp
?????文件???????3211??2017-06-15?17:00??Laser_Motor\Laser_Motor.LST
?????文件???????8466??2017-06-15?17:00??Laser_Motor\Laser_Motor.M51
?????文件???????2496??2017-06-15?17:00??Laser_Motor\Laser_Motor.OBJ
?????文件????????968??2017-06-16?16:30??Laser_Motor\Laser_Motor.Opt
?????文件??????????0??2017-06-16?16:30??Laser_Motor\Laser_Motor.plg
?????文件???????1666??2017-06-15?23:14??Laser_Motor\Laser_Motor.Uv2
????.......???????968??2017-06-15?23:14??Laser_Motor\Laser_Motor_Opt.Bak
????.......??????1623??2017-06-15?16:06??Laser_Motor\Laser_Motor_Uv2.Bak
?????目錄??????????0??2017-06-16?16:30??Laser_Motor
-----------?---------??----------?-----??----
????????????????23200????????????????????13
評論
共有 條評論