代码本身没有错,但是按键好像没什么用,实现不了改变周期,刚接触,不知道哪里错了😭,该怎么修改呢
#include<reg52.h>
#include<stdio.h>
sbit P0_0=P0^0;//定义输出波形引脚
sbit K1=P1^0;//增加键
sbit K2=P1^1;//减少键
unsigned char i=0;
unsigned char PWM=123;
void time0() interrupt 1 //内部定时器中断周期5ms
{
TH0=(65536-2500)/256;
TL0=(65536-2500)%256;
P0_0=~P0_0;
}
void main()
{
TR0=1;
TMOD=0x21;
ET0=1;//定时器0中断
EA=1; //开启总中断
while(1){
if(K1==0){
while(K1==0);
if(PWM!=(65536-2500)/256)
PWM=PWM+10;
}
if(K2==0){
while(K2==0);
if(PWM!=(65536-2500)%256)
PWM=PWM-10;
}
}
}