1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > 四位共阳极数码管显示函数_74LS164驱动4位共阳数码管代码

四位共阳极数码管显示函数_74LS164驱动4位共阳数码管代码

时间:2024-04-08 07:07:13

相关推荐

四位共阳极数码管显示函数_74LS164驱动4位共阳数码管代码

#include"reg52.h"

#defineu16unsignedint

#defineu8unsignedchar

sbitCLK=P2^0;

sbitDAT=P2^1;

u8codetab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xbf,0xff};//0-9

全灭

//

函数声明

voidSend_Byte(u8byte);

voidDelay_ms(u16z);

voidDisplay(u16number);

//

主函数

voidmain()

{

while(1)

{

Display(1111);

Delay_ms(3000);

//

Display(2222);

//

Delay_ms(3000);

}

}

//

数码管显示函数

voidDisplay(u16number)

{

u8qian,bai,shi,ge;

qian=number/1000;

Send_Byte(qian);

Delay_ms(5);

bai=number%1000/100;

Send_Byte(bai);

Delay_ms(5);

shi=number%100/10;

Send_Byte(shi);

Delay_ms(5);

ge=number%1000;

Send_Byte(ge);

Delay_ms(5);

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。