数码管:
#include "reg51.h"
void delay(unsigned int n)
{
while (n)
--n;
}
void main(void)
{ //
unsigned char num[] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d,
0x7d, 0x07, 0x7f, 0x6f, 0x77, 0x7c,
0x39, 0x5e, 0x79, 0x71, 0x00};
unsigned int i = 0;
P1 &= 0x00;//清一下引脚上的状态
P1 |= 0x01; //选择某个位
//P1 |= 0x01;
while(1)
{
//P0 &= 0x00;
//P0 |= num[i];//点亮 数码段
P0 = num[i];
P1 = 0x01<<(i%4);
++i;
if (i==17)
i = 0;
delay(300000);
}
//return 0;
while(1);
}
联系:
1、在某一位显示一个数字
void displayNum(int dig,int n)
2、实现显示数据的函数