共阴极8段数码管

http://www.waveshare.net/shop/74HC138-price.htm

http://wenku.baidu.com/view/7447a923482fb4daa58d4b18.html

http://wenku.baidu.com/view/fb334f28bd64783e09122b97.html


1. 通过P37将LE拉高

2. 通过设置P00~P07给定欲输出的数字
3. 通过P37将LE拉低,以所存step2给出的数字


4. 通过P20~P22选择一个数码管(其余数码管全灭)
5. 延时

6. 通过P20~P22放弃step4选择的数码管(数码管全灭)


#include
#define uchar unsigned char
#define uint  unsigned int

uchar code table[16] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x58,0x5e,0x79,0x71};
uchar code LED_W[8] = {0,1,2,3,4,5,6,7};

void delay(uint i)
{
	uint x,j;
	for(j=0;j 7 || value > 15)
		return;
	P0 = table[value];
	P2 = LED_W[digit];
	delay(delay_ms);	
}

void main(void)
{
	uchar i,j,k;
	while(1) {
		for(k=0;k<16;k++) {
			for(j=0;j<50;j++){
				for(i=0;i<8;i++) {
					display(i, k, 1);
				}
			}
		}  
	}
}



你可能感兴趣的:(misc,delay,table,c)