目录
- #include <REG52.H>
- #define uchar unsigned char
- #define uint unsigned int
- sbit LIGHT_ON=P1^2;
- uchar icount;
-
- void timer0isr(void) interrupt 1 using 1
- {
- TH0 = 0x3C;
- TL0 = 0xB0;
- icount++;
- if(icount == 10)
- {
- icount = 0;
- LIGHT_ON = !LIGHT_ON;
- }
- }
-
- void main(void)
- {
- icount = 0;
- TMOD = 0x01;
- LIGHT_ON = 1;
- TH0 = 0x3C;
- TL0 = 0xB0;
- EA = 1;
- ET0 = 1;
- TR0 = 1;
-
- while(1);
-
- }