共阴极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<reg52.h>
#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<i;j++)
		for(x=0;x<=148;x++)
			;	
}

void display(uchar digit, uchar value, uint delay_ms)
{
	if(digit > 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);
				}
			}
		}  
	}
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

YasinLeeX

再来一杯西湖龙井。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值