<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          AVR單片機(jī)1602液晶程序

          作者: 時(shí)間:2016-11-29 來(lái)源:網(wǎng)絡(luò) 收藏
          端口定義在程序里面采用8位數(shù)據(jù)模式,程序測(cè)試通過(guò).
          #include
          #include
          #define uchar unsigned char
          #define uint unsigned int
          #pragma data:code
          uchar shu;
          const uchar table[15]={
          "yinqing@163.com"
          };
          const uchar table1[]={
          "www.51hei.com "
          };
          /**********************************/
          /************延時(shí)子程序************/
          /**********************************/
          void delay(uint z)//延時(shí)
          {
          uint x,y;
          for(x=500;x>0;x--)
          for(y=z;y>0;y--);
          }
          /**********************************/
          /***********寫指令子程序***********/
          /**********************************/
          void xeizhi(uchar tem)//寫指令子程序
          {
          PORTC&=~BIT(6);//將RS控制端置0
          PORTC&=~BIT(0);//將RW控制端置0
          delay(10);
          PORTA=tem;//將要讀的指令放到PA口
          PORTC|=BIT(0);//將使能端置0
          delay(10);
          PORTC&=~BIT(0);//將使能端置1
          }
          /**********************************/
          /************讀數(shù)子程序************/
          /**********************************/
          void duzhi(uchar tee)//寫數(shù)子程序
          {
          PORTC|=BIT(6);//將RS控制端置1
          PORTC&=~BIT(0);//將RW控制端置0
          delay(10);
          PORTA=tee;//將要讀的數(shù)放到PA口
          PORTC|=BIT(0);//將使能端置0
          delay(10);
          PORTC&=~BIT(0);//將使能端置1
          }
          /**********************************/
          /***************主程序*************/
          /**********************************/
          void main()
          {
          DDRA=0xff;
          DDRC|=BIT(6)|BIT(7)|BIT(0);//將3個(gè)控制端全部設(shè)為輸出
          PORTC&=~BIT(7);//將RW端置0
          xeizhi(0x01);
          xeizhi(0x38);
          xeizhi(0x0c);
          xeizhi(0x06);
          /*******************第一行顯示****************/
          xeizhi(0x80);//將數(shù)據(jù)放顯示區(qū)
          for(shu=0;shu<15;shu++)
          duzhi(table[shu]);
          /*******************第二行顯示****************/
          xeizhi(0xc0);//將數(shù)據(jù)放在顯示區(qū)
          for(shu=0;shu<15;shu++)//查詢15次得到要顯示的數(shù)
          duzhi(table1[shu]);//查表得到想要的數(shù),和上面結(jié)合妙妙啊!
          while(1);
          }


          關(guān)鍵詞: AVR單片機(jī)1602液

          評(píng)論


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

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();