標(biāo)題: 單片機(jī)74LS138譯碼器應(yīng)用 [打印本頁(yè)]

作者: 402875109    時(shí)間: 2020-7-17 16:04
標(biāo)題: 單片機(jī)74LS138譯碼器應(yīng)用
/***************************************
*********74LS138譯碼器應(yīng)用******************
*****************************************/
#include "reg51.h"                         //此文件中定義了單片機(jī)的一些特殊功能寄存器
#include "intrins.h"

typedef unsigned int u16;          //對(duì)數(shù)據(jù)類型進(jìn)行聲明定義
typedef unsigned char u8;
/*************************************
*********    延時(shí)子函數(shù)   *************
**************************************/
void delayms(u16 ms)
{
   u8 i;
   while(ms--)
   {
        for(i=0; i<120; i++);
   }
}
/*******************************************************
***********************************************************/
void main()
{
   P1=0xff;
   while(1)
   {
          P1=(P1+1)%16;         //低4位在0~15取值,使154譯碼器輸入4位為0000~1111
          delayms(500);         //經(jīng)譯碼器輸出0~15中對(duì)應(yīng)引腳輸出0,
   }

}





歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1