八段数码管静止显示:
#include <reg51.h>
#define uchar unsigned char
uchar code tab[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void delay(int count)
{int i,j;
for(i=0;i<count;i++)
for(j=0;j<120;j++)
; }
void main(void)
{while(1)
{P0=0x0;
P3=1;
P0=tab[0];
delay(1);
P0=0X0;
P3=2;
P0=tab[1];
delay(1);
P0=0x0;
P3=4;
P0=tab[2];
delay(1);
P0=0x0;
P3=8;
P0=tab[3];
delay(1);
P0=0x0;
P3=16;
P0=tab[4];
delay(1);
P0=0x0;
P3=32;
P0=tab[5];
delay(1);
P0=0x0;
P3=64;
P0=tab[6];
delay(1);
}
}
效果:
简单计数的数码管:
#include<reg51.h>
#define uchar unsigned char
uchar code tab[10]={0x3f,0x06,0x5b,0x