📄 1.c
字号:
#include <pic.h>
unsigned char a,b,c=0;
const char xianshi[]={0x3f,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f};
void initial()
{
INTCON=0x00;
ADCON1=0x07;
}
void timer0initial()
{ PSA=0;
T0CS=0;
T0IF=0;
GIE=1;
T0IE=1;
TMR0=0xf0;
PS0=1;
PS1=1;
PS2=1;
}
void delay()
{ int i;
for(i=0;i<10;i++)
i=i;
}
void interrupt INT_TIMER1()
{
if(T0IF==1)
{ T0IF=0;
TMR0=0xf0;
a++;
if(a==100)
{b++;
if(b==10) {c++; b=0;}
if(c==10) c=0;
}
}
}
void main()
{
TRISB=0x00;
TRISD=0x00;
initial();
timer0initial();
while(1)
{ PORTB=0xf7;
PORTD=xianshi[b]; delay(); PORTD=0x00;
PORTB=0xef;
PORTD=xianshi[c];delay(); PORTD=0x00;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -