標題: BCD譯碼數(shù)碼管顯示數(shù)字 單片機程序 [打印本頁]
作者: 123321gjx 時間: 2021-4-10 19:32
標題: BCD譯碼數(shù)碼管顯示數(shù)字 單片機程序
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
//數(shù)碼管位碼
uchar code DSY_Index[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};//待顯示數(shù)字(10為不顯示)
uchar code BCD_CODE[]={2,0,1,0,10,3,10,5};
//延時
void DelayMS(uint ms)
{
uchar i;
while(ms--) for(i=0;i<120;i++);
}
//主程序
void main()
{
uchar k;
while(1)
{
for(k=0;k<8;k++)
{
P2=DSY_Index[k];
P1=BCD_CODE[k];
DelayMS(1);
}
}
}
歡迎光臨 (http://www.torrancerestoration.com/bbs/) |
Powered by Discuz! X3.1 |