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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > AVR128的程序——1602液晶顯示

          AVR128的程序——1602液晶顯示

          作者: 時(shí)間:2016-11-22 來源:網(wǎng)絡(luò) 收藏
          #include
          #define uchar unsigned char
          #define uint unsigned int
          unsigned char table[]="I love mcu!";
          unsigned char table1[]="very much!";
          #define rsout DDRB |= (1<<5)
          #define rsset PORTB |=(1<<5)
          #define rsclr PORTB &=~(1<<5)
          #define rwout DDRB |= (1<<6)
          #define rwset PORTB |= (1<<6)
          #define rwclr PORTB &= ~(1<<6)
          #define enout DDRB |= (1<<7)
          #define enset PORTB |= (1<<7)
          #define enclr PORTB &= ~(1<<7)
          void mcu_init(void);
          void Delayms(uint MS)
          {
          uint i,j;
          for( i=0;i
          for(j=0;j<1141;j++);
          }
          void write_com(uchar com)
          {
          rsclr;
          rwclr;
          enclr;
          PORTA=com;
          Delayms(5);
          enset;
          Delayms(5);
          enclr;
          }
          void write_data(uchar date)
          {
          rsset;
          rwclr;
          PORTA=date;
          Delayms(5);
          enset;
          Delayms(5);
          enclr;
          }
          void initlcd(void)
          {
          write_com(0x38);
          Delayms(5);
          write_com(0x01);
          Delayms(5);
          write_com(0x06);
          Delayms(5);
          write_com(0x0c);
          Delayms(5);
          }
          void main(void)
          {
          uint num=0;
          mcu_init();
          Delayms(30);
          initlcd();
          write_com(0x80);
          for(num=0;num<11;num++)
          {
          write_data(table[num]);
          Delayms(20);
          }
          write_com(0x80+0x40);
          for(num=0;num<10;num++)
          {
          write_data(table1[num]);
          Delayms(20);
          }
          while(1);
          }
          void mcu_init(void)
          {
          DDRA = 0XFF;
          PORTA = 0XFF;
          DDRC = 0XFF;
          PORTC = 0XFF;
          DDRF |= 0X0E;
          PORTF |= 0X0E;
          PORTF &= 0xF0;
          DDRB |= 0X10;
          PORTB |= 0X10;
          rsout;
          rwout;
          enout;
          }



          關(guān)鍵詞: AVR1281602液晶顯

          評(píng)論


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

          關(guān)閉