程序无错,烧录成功
单片机型号普中51实验板
在板子上无运行
#include <REGX52.H>
sbit LED=P2^0;
sbit Motor=P1^0;
sbit key1=P3^1;
sbit key3=P3^2;
sbit key2=P3^0;
sbit key4=P3^3;
void PWM(unsigned char j){
unsigned char a;
for(a=0;a<=j;a++)
Motor=1;
for(a=0;a<10-j;a++)
Motor=0;
}
void main(){
while(1){
if(key1==0){
while(key1==0);
LED=~LED;
}
if(key2==0){
while(key3!=0||key4!=0){
PWM(10);}
}
if(key3==0){
while(key2!=0||key4!=0){
PWM(4);}
}
if(key4==0){
while(key3!=0||key2!=0){
PWM(0);}
}
}
}