色婷婷AⅤ一区二区三区|亚洲精品第一国产综合亚AV|久久精品官方网视频|日本28视频香蕉

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > LCD1602液晶顯示屏顯示時(shí)鐘且能修改時(shí)間

          LCD1602液晶顯示屏顯示時(shí)鐘且能修改時(shí)間

          作者: 時(shí)間:2016-12-01 來(lái)源:網(wǎng)絡(luò) 收藏
          CODE:

          /***************************************
          程序功能:
          LCD液晶顯示屏顯示時(shí)鐘并且可以修改時(shí)間
          ***************************************/
          #include
          #define uint unsigned int
          #define uchar unsigned char
          sbit K1=P1^0;//設(shè)置三個(gè)獨(dú)立鍵盤
          sbit K2=P1^3;
          sbit K3=P1^5;
          sbit lcdwrite=P2^5;
          sbit lcddatecommand=P2^6;
          sbit lcde=P2^7;
          uchar code firstline[]="2013-06-03";
          uchar code secondline[]="00-00-00";
          uchar i;
          uchar hour,minutes,seconds;
          uchar count,num;
          uchar cnt;
          void delay(uint z)
          {
          uint x,y;
          for(x=z;x>0;x--)
          {
          for(y=0;y<=112;y++)
          {
          }
          }
          }
          void write_command(uchar command)
          {
          lcddatecommand=0;
          lcdwrite=0;
          P0=command;
          delay(1);
          lcde=1;
          delay(1);
          lcde=0;
          }
          void write_date(uchar date)
          {
          lcddatecommand=1;
          lcdwrite=0;
          P0=date;
          delay(1);
          lcde=1;
          delay(1);
          lcde=0;
          }
          void LCDinit()
          {
          lcde=0;
          write_command(0x38);//設(shè)置16*2顯示,5*7點(diǎn)陣,8位數(shù)據(jù)接口
          write_command(0x0f);//設(shè)置開(kāi)顯示,不顯示光標(biāo)
          write_command(0x06);// 寫(xiě)一個(gè)字符后地址指針加1
          write_command(0x80);
          for(i=0;i<10;i++)
          {
          write_date(firstline[i]);
          delay(1);
          }
          write_command(0x80+0x40);
          for(i=0;i<8;i++)
          {
          write_date(secondline[i]);
          delay(1);
          }
          }
          void Time0init()
          {
          TMOD=0x01;//開(kāi)啟定時(shí)器1
          TH0=(65536-50000)/256;
          TL0=(65536-50000)%256;
          EA=1;
          ET0=1;
          TR0=1;
          }
          void Clockinit()
          {
          hour=0;
          minutes=0;
          seconds=0;
          count=0;
          num=0;
          }


          上一頁(yè) 1 2 下一頁(yè)

          評(píng)論


          技術(shù)專區(qū)

          關(guān)閉