//51单片机控制3位7段共阴数码管 p0口控制 abcdefg dp ,
//p2.0-p2.2控制123位,----注意:没有用P2.3。
//要使其间隔1S分别显示123,231,321,213...........无限循环
//下列程序,经过仿真,符合要求。
#include
#define uchar unsigned char
sbit bit1 = P2^0;
sbit bit2 = P2^1;
sbit bit3 = P2^2;
uchar code dulatab[] = //数字编码0-9
{0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f};
//----------------------------------------------------------------
void delay(uchar time)
{
uchar i, j;
for(i = 0; i < time; i++) for(j = 0; j < 110; j++);
}
//----------------------------------------------------------------
void disp_num(uchar a , b, c)
{
uchar i;
for(i = 1; i < 250; i++) {
P2 = 255; //关显示.
P0 = dulatab[a];
bit1 = 0; delay(4);
P2 = 255; //关显示.
P0 = dulatab[b];
bit2 = 0; delay(4);
P2 = 255; //关显示.
P0 = dulatab[c];
bit3 = 0; delay(4);
}
}
//----------------------------------------------------------------
void main()
{
while(1) {
//要使其间隔1S分别显示123,231,321,213...........无限循环.
disp_num(1, 2, 3);
disp_num(2, 3, 1);
disp_num(3, 2, 1);
disp_num(2 , 1, 3);
// disp_num(? , ?, ?); 还想显示?内容,楼主可自行编写.
// disp_num(? , ?, ?);
}
}
//----------------------------------------------------------------
//51单片机控制3位7段共阴数码管 p0口控制 abcdefg dp ,
//p2.0-p2.3控制123位,
//要使其间隔1S分别显示123,231,321,213...........无限循环
#include
#define uchar unsigned char
sbit bit1=P2^0;
sbit bit2=P2^1;
sbit bit3=P2^2;
uchar code dulatab[]={0x3f,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f}; //数字编码0-9
void delay(uchar time)
{
uchar i,j;
for(i=0;i