(玩電子) 電子技術學習與研究
當前位置:單片機教程網 >> MCU設計實例 >> 瀏覽文章

基于單片機的12864液晶顯示動畫效果設計

作者:佚名   來源:本站原創   點擊數:x  更新時間:2012年01月02日   【字體:



 

該設計顯示效果為:12864上半屏顯示靜態漢字(* * *相信你會成功的!),下半屏顯示動畫效果(錘子砸釘子,錘子落下釘子釘入的循環效果),完整的程序源代碼從這里下載 http://www.rchszg.icu/f/12864dh.rar ,注意這種是使用的不帶字庫的屏幕.電路按上面的圖,程序已經測試成功。

#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit lcdcs1=P3^7;
sbit lcdcs2=P3^6;
sbit rs=P3^5;
sbit rw=P3^4;
sbit lcden=P3^3;
uint unm,mcu,unm1,unm2,unm3,uum;
uchar code table[]={0x00,0x00,0x08,0x88,0x88,0x9E,0xE4,0x44,0x5C,0x47,0x44,0xC4,0x04,0x00,0x00,0x00,
                    0x00,0x00,0x00,0x10,0x90,0x50,0x30,0xFF,0x28,0x48,0x88,0x88,0x00,0x00,0x00,0x00,
                    0x00,0x80,0x40,0xF0,0x08,0x06,0x10,0x50,0x50,0xFF,0xA8,0xA8,0x88,0x80,0x00,0x00,
                    0x00,0x20,0x20,0xA0,0xFF,0x90,0x10,0x00,0xF0,0x48,0x48,0x48,0x08,0xF8,0x00,0x00,
                    0x00,0x00,0x00,0x3F,0x04,0x02,0x01,0x01,0x02,0x04,0x20,0x7F,0x00,0x00,0x00,0x00,
                    0x00,0x20,0x1A,0x01,0x08,0x10,0x00,0x03,0x08,0x10,0x00,0x09,0x11,0x31,0x00,0x00,
                    0x01,0x00,0x00,0x3F,0x00,0x01,0x01,0x01,0x01,0x7F,0x00,0x04,0x08,0x07,0x00,0x00,
                    0x08,0x04,0x03,0x00,0x7F,0x00,0x01,0x00,0x1F,0x09,0x09,0x09,0x30,0x1F,0x00,0x00,
     0x80,0x40,0x20,0xF8,0x06,0x10,0x10,0x50,0x50,0x4A,0xAC,0xA8,0x08,0x08,0x08,0x00,
                    0x00,0x80,0x40,0xF0,0x0E,0x00,0x40,0x30,0x2E,0xA0,0x10,0x50,0x30,0x00,0x00,0x00,
                    0x00,0x80,0x40,0x20,0x50,0x4C,0x43,0x24,0x28,0x10,0x20,0x40,0xC0,0x80,0x80,0x00,
                    0x00,0x00,0x00,0xE0,0x20,0x20,0x27,0x78,0x90,0x10,0x12,0xC4,0x00,0x00,0x00,0x00,
                    0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x1D,0x15,0x15,0x12,0x1E,0x00,0x00,0x00,0x00,
                    0x01,0x00,0x00,0x3F,0x00,0x08,0x06,0x10,0x20,0x3F,0x00,0x02,0x04,0x0C,0x00,0x00,
                    0x01,0x00,0x02,0x32,0x2A,0x26,0x22,0x11,0x15,0x19,0x31,0x00,0x00,0x00,0x00,0x00,
                    0x20,0x10,0x0C,0x03,0x09,0x11,0x0F,0x10,0x09,0x06,0x09,0x10,0x20,0x40,0x78,0x00,
     0x00,0x00,0x20,0x20,0xF0,0x10,0x10,0x40,0x40,0xC0,0x3E,0x20,0x20,0xE0,0x00,0x00,
                    0x00,0xC0,0x60,0x50,0x2C,0xE0,0x80,0x40,0xA0,0x38,0x26,0x10,0xF0,0x00,0x00,0x00,
                    0x00,0x00,0x00,0xFC,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                    0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                    0x02,0x02,0x02,0x02,0x21,0x11,0x09,0x04,0x03,0x10,0x20,0x10,0x0E,0x01,0x00,0x00,
                    0x00,0x07,0x19,0x09,0x08,0x1F,0x00,0x00,0x00,0x03,0x10,0x20,0x1F,0x00,0x00,0x00,
                    0x00,0x00,0x00,0x19,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                    0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

     0x00,0x08,0x1C,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xDC,0xC8,0xC0,0xC0,
     0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE0,0xF0,0xF0,0xF0,0xF0,0xE0,
      0xE0,0xF8,0xFC,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFE,0xFC,0xF8,0xE0,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x10,0x38,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x3B,0x13,0x03,0x03,
      0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x07,0x0F,0x0F,0x0F,0x0F,0x07,
     0x03,0x0F,0x1F,0x3F,0x3F,0x7F,0x7F,0x7F,0x7F,0x7F,0x3F,0x3F,0x1F,0x0F,0x03,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 

     0xE0,0xF8,0xFC,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFE,0xFC,0xF8,0xE0,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0xE0,0xF8,0xFC,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFE,0xFC,0xF8,0xE0,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x03,0x0F,0x1F,0x3F,0x3F,0x7F,0x7F,0x7F,0x7F,0x7F,0x3F,0x3F,0x1F,0x0F,0x03,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x03,0x0F,0x1F,0x3F,0x3F,0x7F,0x7F,0x7F,0x7F,0x7F,0x3F,0x3F,0x1F,0x0F,0x03,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

     0x10,0x18,0x18,0x1C,0x1C,0xFE,0xFE,0xFE,0xFE,0xFE,0x1C,0x1C,0x18,0x18,0x10,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x0F,0x3F,0xFF,0x3F,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

     0x00,0x08,0x1C,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xDC,0xC8,0xC0,0xC0,
     0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xE0,0xF0,0xF0,0xF0,0xF0,0xE0,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0xE0,0xF8,0xFC,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFE,0xFC,0xF8,0xE0,0x00,
     0x00,0x10,0x38,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x3B,0x13,0x03,0x03,
     0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x07,0x0F,0x0F,0x0F,0x0F,0x07,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x03,0x0F,0x1F,0x3F,0x3F,0x7F,0x7F,0x7F,0x7F,0x7F,0x3F,0x3F,0x1F,0x0F,0x03,0x00,

     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0xE0,0xF8,0xFC,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFE,0xFC,0xF8,0xE0,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0xE0,0xF8,0xFC,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFE,0xFC,0xF8,0xE0,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x03,0x0F,0x1F,0x3F,0x3F,0x7F,0x7F,0x7F,0x7F,0x7F,0x3F,0x3F,0x1F,0x0F,0x03,0x00,
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
     0x03,0x0F,0x1F,0x3F,0x3F,0x7F,0x7F,0x7F,0x7F,0x7F,0x3F,0x3F,0x1F,0x0F,0x03,0x00,
     };
     
void delay(int z)
 {
  int x,y;
   for(x=z;x>0;x--)
    for(y=0;y>0;y--);
 }
void writen_com(uchar com)
 {
  lcden=0;
  delay(1);
  rs=0;
  lcden=1;
  P0=com;
  delay(1);
  lcden=0;
  rs=1;
 }
void writen_dat(uchar dat)
 {
  lcden=0;
  delay(1);
  rs=1;
  lcden=1;
  P0=dat;
  lcden=0;
  delay(1);
  rs=0;
 }
void init()
 {
  mcu=0;
  lcden=1;
  rw=0;
  writen_com(0x3f);
  writen_com(0xc0);
  writen_com(0xb8);
  writen_com(0x40);
  lcdcs1=1;
  lcdcs2=0;
  }
 void main()
 {
  init();
 for(unm1=0;unm1<3;unm1++)
   {
    for(unm=mcu;unm<mcu+128;unm++)
     {
      writen_dat(table[unm]);
    delay(1);
     }
      lcdcs1=!lcdcs1;
      lcdcs2=!lcdcs2;
      mcu=mcu+128;
     uum=mcu;
 }

 while(1)
 { 
       mcu=uum;
    lcdcs1=1;
       lcdcs2=0;
 for(unm2=0;unm2<1;unm2++)
  {
   writen_com(0xc0);
      writen_com(0xbc);
      writen_com(0x40);
 
   for(unm=mcu;unm<mcu+128;unm++)
     {
      writen_dat(table[unm]);
    delay(1);
     }
      lcdcs1=!lcdcs1;
      lcdcs2=!lcdcs2;
      mcu=mcu+128;
   }
 for(unm2=0;unm2<1;unm2++)
  {
   writen_com(0xc0);
      writen_com(0xbc);
      writen_com(0x40);
 
   for(unm=mcu;unm<mcu+128;unm++)
     {
      writen_dat(table[unm]);
     }
      lcdcs1=!lcdcs1;
      lcdcs2=!lcdcs2;
      mcu=mcu+128;
   }
 for(unm3=0;unm3<1;unm3++)
  {
   writen_com(0xc0);
      writen_com(0xbe);
      writen_com(0x40);
   lcdcs1=1;
       lcdcs2=0;
 
   for(unm=mcu;unm<mcu+128;unm++)
     {
      writen_dat(table[unm]);
  
     }
      lcdcs1=!lcdcs1;
      lcdcs2=!lcdcs2;
      mcu=mcu+128;
   }
 for(unm3=0;unm3<1;unm3++)
  {
   writen_com(0xc0);
      writen_com(0xbe);
      writen_com(0x40);
 
   for(unm=mcu;unm<mcu+128;unm++)
     {
      writen_dat(table[unm]);
    delay(1);
     }
      lcdcs1=!lcdcs1;
      lcdcs2=!lcdcs2;
      mcu=mcu+128;
   }


   lcdcs1=1;
       lcdcs2=0;
   delay(335556);
 for(unm2=0;unm2<1;unm2++)
  {
   writen_com(0xc0);
      writen_com(0xbc);
      writen_com(0x40);
 
   for(unm=mcu;unm<mcu+128;unm++)
     {
      writen_dat(table[unm]);
    delay(1);
     }
      lcdcs1=!lcdcs1;
      lcdcs2=!lcdcs2;
      mcu=mcu+128;
   }
 for(unm2=0;unm2<1;unm2++)
  {
   writen_com(0xc0);
      writen_com(0xbc);
      writen_com(0x40);
 
   for(unm=mcu;unm<mcu+128;unm++)
     {
      writen_dat(table[unm]);
    delay(1);
     }
      lcdcs1=!lcdcs1;
      lcdcs2=!lcdcs2;
      mcu=mcu+128;
   }
 for(unm3=0;unm3<1;unm3++)
  {
   writen_com(0xc0);
      writen_com(0xbe);
      writen_com(0x40);
   lcdcs1=1;
       lcdcs2=0;
 
   for(unm=mcu;unm<mcu+128;unm++)
     {
      writen_dat(table[unm]);
  
     }
      lcdcs1=!lcdcs1;
      lcdcs2=!lcdcs2;
      mcu=mcu+128;
   }
 for(unm3=0;unm3<1;unm3++)
  {
   writen_com(0xc0);
      writen_com(0xbe);
      writen_com(0x40);  
   for(unm=mcu;unm<mcu+128;unm++)
     {
      writen_dat(table[unm]);
    delay(1);
     }
      lcdcs1=!lcdcs1;
      lcdcs2=!lcdcs2;
      mcu=mcu+128;
   }
  delay(335556);
  }
 }
發表評論】【告訴好友】【收藏此文】【關閉窗口

文章評論

相關文章

街机奔驰宝马电玩城 手机赚钱软件大全 篮球场地坪漆价格 老公隐瞒炒股亏了260万 快乐扑克3走势图新浪 nba 录像 南宁麻将胡牌算法 2020白小姐精选四不像大全 短线炒股快速入门必读 微乐贵州捉鸡麻将 大圣快点手机下载 终于知道四方河南麻将一直赢 35选7近500期走势图 五粮液股票 pc蛋蛋金蛋 天成配资 开元棋牌连输几十把