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

          新聞中心

          proteus 1602液晶程序

          作者: 時(shí)間:2016-11-13 來源:網(wǎng)絡(luò) 收藏
          proteus1602液晶是LM016L

          #include
          #include
          #include
          #define uchar unsigned char
          #define uint unsigned int
          #pragma data:code
          const uchar table[]="I LOVE CHINA";
          const uchar table1[]="MADE BY LYQ" ;
          void delay(uint ms)
          {
          uint i,j;
          for(i=0;ifor(j=0;j<1141;j++);
          }
          void write_com(uchar com)
          {
          PORTD&=~BIT(4); // RS
          PORTD&=~BIT(5);// RW
          PORTB=com;
          //PORTD&=~BIT(6);// E
          PORTD|=BIT(6);
          delay(1);
          PORTD&=~BIT(6);

          }

          本文引用地址:http://cafeforensic.com/article/201611/316375.htm

          void write_data(uchar data)
          {
          PORTD|=BIT(4); // RS
          PORTD&=~BIT(5);// RW
          PORTB=data;
          //PORTD&=~BIT(6);// E
          PORTD|=BIT(6);
          delay(1);
          PORTD&=~BIT(6);
          }

          void main()
          {
          uchar i;
          DDRB=0XFF;
          DDRD|=BIT(4)|BIT(5)|BIT(6);
          PORTD&=~BIT(6);

          write_com(0x38);
          delay(5);
          write_com(0x01);//clear screen//清屏命令非常重要,沒有出現(xiàn)亂碼
          delay(5);
          write_com(0x0f);
          delay(5);
          write_com(0x06);
          delay(5);
          write_com(0x80+0x10);
          delay(5);

          for(i=0;i<12;i++)
          {
          write_data(table[i]);
          delay(1);
          }
          write_com(0x80+0x40+0x10);
          delay(5);

          for(i=0;i<11;i++)
          {
          write_data(table1[i]);
          delay(1);
          }
          delay(1000);
          for(i=0;i<16;i++)
          {
          write_com(0x1c);//屏幕左移16次,不是0x18
          delay(200);

          }

          }



          關(guān)鍵詞: proteus1602液

          評(píng)論


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

          關(guān)閉