#include <reg52.h>
#include <function.h> //详见第六章第8讲
#include <timer.h> //详见第八章第11讲
#include <infrared.h> //详见第十三章第2讲
sbit PWMOUT=P1^7;
u8 highval = 10;
void
main()
{
LED_Init();
EA = 1;
InitInfrared();
TIM0_Init(100,34);
ShowNumber(highval);
while
(1)
{
if
(irflag)
{
irflag = 0;
if
(ircode[2]==0x45)highval=5;
if
(ircode[2]==0x46)highval=7;
if
(ircode[2]==0x47)highval=10;
if
(ircode[2]==0x44)highval=12;
if
(ircode[2]==0x40)highval=14;
if
(ircode[2]==0x43)highval=16;
if
(ircode[2]==0x07)highval=19;
if
(ircode[2]==0x15)highval=22;
if
(ircode[2]==0x09)highval=24;
ShowNumber(highval);
}
}
}
void
TIM0_IRQHandler() interrupt 1
{
static
u8 pwm=0;
TH0 = T0RH;
TL0 = T0RL;
pwm++;
if
(pwm>=200)pwm=0;
if
(pwm%10==0)SEG_Scan();
if
(pwm<highval)PWMOUT=1;
else
PWMOUT=0;
}