高手看下这程序~AT89S52单片机,控制直流电机,这样速度好慢,而且一会儿转一会儿不转
#include<reg52.h>#defineucharunsignedcharsbitzz=P1^0;sbitfz=P1^1;ucharPWM;voidmain(){...
#include<reg52.h>
#define uchar unsigned char
sbit zz=P1^0;
sbit fz=P1^1;
uchar PWM;
void main()
{
TMOD=1;
TH0=0xFF;
TL0=0xF6;
EA=1;
ET0=1;
TR0=1;
PWM=80;
zz=0;
fz=1;
while(1)
{
}
}
void timer0() interrupt 1 using 2
{
static uchar a=0;
TH0=0xFF;
TL0=0xF6;
a++;
if(a>=100)
a=0;
if(a<=PWM)
zz=0;
else
zz=1;
} 展开
#define uchar unsigned char
sbit zz=P1^0;
sbit fz=P1^1;
uchar PWM;
void main()
{
TMOD=1;
TH0=0xFF;
TL0=0xF6;
EA=1;
ET0=1;
TR0=1;
PWM=80;
zz=0;
fz=1;
while(1)
{
}
}
void timer0() interrupt 1 using 2
{
static uchar a=0;
TH0=0xFF;
TL0=0xF6;
a++;
if(a>=100)
a=0;
if(a<=PWM)
zz=0;
else
zz=1;
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询