基于單片機(jī)的數(shù)碼管顯示實(shí)現(xiàn)自加功能
本文主要介紹基于MCS-51單片機(jī)的數(shù)碼管顯示實(shí)現(xiàn)自加1功能,從1一直顯示到999.以下是硬件電路圖、功能實(shí)現(xiàn)圖以及源代碼。(電路:使用74HC573鎖存器控制段選,74H138控制位選;)
本文引用地址:http://www.ex-cimer.com/article/171112.htm實(shí)現(xiàn)數(shù)碼管自加的代碼:
#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,0x39,0x5e,0x79,0x71}; //顯示數(shù)字表
uchar flag,bai,shi,ge;
uint temp;
void xunhuan();
void delay(uint z);
void init();
void main()
{
init();
while(1)
{
if(flag==20)
{
flag=0;
temp++;
if(temp==1000)
{
temp=0;
}
}
bai=temp/100;
shi=temp%100/10;
評(píng)論