PWM驱动直流电机程序 /*用PWM控制电机脉冲频率应控制在25HZ~35HZ之间*/
/*定时1ms,1个周期30ms,脉冲频率为33HZ */
/* */
#include
typedef unsigned char uchar;
sbit P0_0=P0^0;
sbit P0_1=P0^1;
sbit P0_2=P0^2;
sbit P0_3=P0^3;
sbit P0_4=P0^4;
sbit P2_0=P2^0;
sbit P2_1=P2^1;
sbit P2_2=P2^2;
sbit P2_3=P2^3;
sbit P2_4=P2^4;
sbit P3_4=P3^4;
uchar time=0;
uchar period=30;
uchar high=10;
uchar th0=0;
uchar tl0=1;
1