找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3158|回复: 0
打印 上一主题 下一主题
收起左侧

nokia5110 51单片机 控制 程序

[复制链接]
跳转到指定楼层
楼主

51单片机控制Nokia5110uv4工程

部分源码预览:
  1. #include "lcd.h"  
  2. #include "font.h"  
  3.   
  4. /*--------------------------------------------------------------*/  
  5. //写入一个字节(数据或指令)  
  6. //wByte:    待写入的数据  
  7. //datOrCmd: 1-数据, 0-指令  
  8. void writeByte(unsigned char wByte, unsigned char datOrCmd)  
  9. {  
  10.     unsigned char i;  
  11.     CS = 0;         //使能  
  12.     DC = datOrCmd;  //1-数据  //0-指令  
  13.     for(i = 8; i; i--)  //8位数据, 先高后低  
  14.     {  
  15.         if(wByte & 0x80) {  
  16.             DIN = 1;  
  17.         }  
  18.         else             {  
  19.             DIN = 0;  
  20.         }  
  21.         CLK = 0;  
  22.         wByte <<= 1;  //移位(延时)  
  23.         CLK = 1;    //上升沿写入  
  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写0  
  35.     }  
  36. }  
  37.   
  38. //x: 0 - 83  
  39. //y: 0 - 5  
  40. void moveTo(unsigned char x, unsigned char y)//设置写数据位置  
  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) //写一个字符  
  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)//写一个字符串  
  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;//硬件复位  
  77.          
  78.     writeCmd(0x21);     //工作模式, 水平寻址, 扩展指令  
  79.     writeCmd(0x07);     //VLCD温度系数,设置0x04~0x07,越小越黑

  80.     writeCmd(0x13);     //设置偏置系统(BSx) 1:48,设置为0x10~0x17   
  81.     writeCmd(128+25);      //设置电压VLCD = 3.06 + 0.06*Vop, 对比度调整,设置为0x80~0xff;128+(0~127)  
  82.   
  83.     writeCmd(0x20);     //工作模式, 水平寻址, 常规指令  
  84.     writeCmd(0x0c);     //普通模式  
  85.     writeCmd(0x80);     //起始页地址0  
  86.     writeCmd(0x40);     //起始列地址0  
  87.     clear();                //清全屏  
  88. }  
复制代码


nokia 5110.zip

30.54 KB, 下载次数: 42, 下载积分: 黑币 -5

工程

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表