#include
#define SEG P2
sbit P1_0 = P1^0;
sbit P1_1 = P1^1;
sbit P1_2 = P1^2;
sbit P1_3 = P1^3;
sbit P1_4 = P1^4;
unsigned char code tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x3c,0x07,0x7f,0x37}; //共阴极
void delay(int x);
void main()
{
while(1) //2015
{
P1_0 =0; //573 低电平使能
SEG =tab[2]; //送段位
P1_1 = 0; //点亮数码管
P1_0 = 1; //关闭锁存
P1_1 = 1; //关闭数码管
P1_0 =0; //573 低电平使能
SEG =tab[0];
P1_2 = 0;
P1_0 = 1;
P1_2 = 1;
P1_0 =0; //573 低电平使能
SEG =tab[1];
P1_3 = 0;
P1_0 = 1;
P1_3 = 1;
P1_0 =0; //573 低电平使能
SEG =tab[5];
P1_4 = 0;
P1_0 = 1;
P1_4 = 1;
}
}
void delay(int x) //6ms*x 23MHZ晶振
{
int i,j;
for( i=0;i for( j =0;j<12000;j++); } #include #define SEG P2 sbit P1_0 = P1^0; sbit P1_1 = P1^1; sbit P1_2 = P1^2; sbit P1_3 = P1^3; sbit P1_4 = P1^4; unsigned char code tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x3c,0x07,0x7f,0x37}; void delay(int x); void main() { while(1) //521 1314 { P1_0 =0; //573 低电平使能 SEG =tab[5]; //送段位 P1_1 = 0; //点亮数码管 delay(166); //延时 P1_0 = 1; //关闭锁存 P1_1 = 1; //关闭数码管 P1_0 =0; //573 低电平使能 SEG =tab[2]; P1_2 = 0; delay(166); P1_0 = 1; P1_2 = 1; P1_0 =0; //573 低电平使能 SEG =tab[1]; P1_3 = 0; delay(166); P1_0 = 1; P1_3 = 1; //////////////////////////////////////////// 1314 P1_0 =0; //573 低电平使能 SEG =tab[1]; //送段位 P1_1 = 0; //点亮数码管 delay(166); //延时 P1_0 = 1; //关闭锁存 P1_1 = 1; //关闭数码管 P1_0 =0; //573 低电平使能 SEG =tab[3]; P1_2 = 0; delay(166); P1_0 = 1; P1_2 = 1; P1_0 =0; //573 低电平使能 SEG =tab[1]; P1_3 = 0; delay(166); P1_0 = 1; P1_3 = 1; P1_0 =0; //573 低电平使能 SEG =tab[4]; P1_4 = 0; delay(166); P1_0 = 1; P1_4 = 1; } } void delay(int x) //6ms*x 23MHZ晶振 { int i,j; for( i=0;i for( j =0;j<12000;j++); }
上一篇:单片机实现60s定时器
下一篇:谈静态数码管