找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 4109|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

nokia5110 51單片機(jī) 控制 程序

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主

51單片機(jī)控制Nokia5110uv4工程

部分源碼預(yù)覽:
  1. #include "lcd.h"  
  2. #include "font.h"  
  3.   
  4. /*--------------------------------------------------------------*/  
  5. //寫(xiě)入一個(gè)字節(jié)(數(shù)據(jù)或指令)  
  6. //wByte:    待寫(xiě)入的數(shù)據(jù)  
  7. //datOrCmd: 1-數(shù)據(jù), 0-指令  
  8. void writeByte(unsigned char wByte, unsigned char datOrCmd)  
  9. {  
  10.     unsigned char i;  
  11.     CS = 0;         //使能  
  12.     DC = datOrCmd;  //1-數(shù)據(jù)  //0-指令  
  13.     for(i = 8; i; i--)  //8位數(shù)據(jù), 先高后低  
  14.     {  
  15.         if(wByte & 0x80) {  
  16.             DIN = 1;  
  17.         }  
  18.         else             {  
  19.             DIN = 0;  
  20.         }  
  21.         CLK = 0;  
  22.         wByte <<= 1;  //移位(延時(shí))  
  23.         CLK = 1;    //上升沿寫(xiě)入  
  24.     }  
  25.     CS = 1;         //禁止  
  26. }  
  27.   
  28. void clear()//清屏  
  29. {  
  30.     unsigned int i;  
  31.     writeCmd(0x80);  
  32.     writeCmd(0x40);  
  33.     for(i = 504; i; i--){  
  34.         writeDat(0x00);//將所有RAM寫(xiě)0  
  35.     }  
  36. }  
  37.   
  38. //x: 0 - 83  
  39. //y: 0 - 5  
  40. void moveTo(unsigned char x, unsigned char y)//設(shè)置寫(xiě)數(shù)據(jù)位置  
  41. {  
  42.     writeCmd(x|0x80);  
  43.     writeCmd(y|0x40);  
  44. }  
  45.   
  46. //x:0~9  
  47. //y:0~2  
  48. void writeChar(unsigned char x, unsigned char y, unsigned char c) //寫(xiě)一個(gè)字符  
  49. {  
  50.     unsigned char i, j;  
  51.     c -= 32;  
  52.     x <<= 3;        
  53.     y <<= 1;        
  54.     for(j = 0; j < 2; j++)  
  55.     {  
  56.         moveTo(x, (y + j));  
  57.         for(i = 0; i < 8; i++)  
  58.             writeDat(font[c][8 * j + i]);  
  59.     }  
  60. }  
  61.   
  62. //x:0~9  
  63. //y:0~2  
  64. void writeString(unsigned char x, unsigned char y, unsigned char *str)//寫(xiě)一個(gè)字符串  
  65. {  
  66.     while(*str && x < 10)  
  67.     {  
  68.         writeChar(x++, y, *str);  
  69.         str++;  
  70.     }  
  71. }  
  72.   
  73. void LCDInit(void)  
  74. {  
  75.     RST = 0;   
  76.     RST = 1;//硬件復(fù)位  
  77.          
  78.     writeCmd(0x21);     //工作模式, 水平尋址, 擴(kuò)展指令  
  79.     writeCmd(0x07);     //VLCD溫度系數(shù),設(shè)置0x04~0x07,越小越黑

  80.     writeCmd(0x13);     //設(shè)置偏置系統(tǒng)(BSx) 1:48,設(shè)置為0x10~0x17   
  81.     writeCmd(128+25);      //設(shè)置電壓VLCD = 3.06 + 0.06*Vop, 對(duì)比度調(diào)整,設(shè)置為0x80~0xff;128+(0~127)  
  82.   
  83.     writeCmd(0x20);     //工作模式, 水平尋址, 常規(guī)指令  
  84.     writeCmd(0x0c);     //普通模式  
  85.     writeCmd(0x80);     //起始頁(yè)地址0  
  86.     writeCmd(0x40);     //起始列地址0  
  87.     clear();                //清全屏  
  88. }  
復(fù)制代碼


nokia 5110.zip

30.54 KB, 下載次數(shù): 42, 下載積分: 黑幣 -5

工程

評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩

相關(guān)帖子

回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表