单片机源程序如下:
//---库函数声明及相关定义---//
#include #include #define unint unsigned int #define unchar unsigned char #define Databus P1 /*液晶数据总线*/ sbit RS=P3^3; /*数据指令 选择*/ sbit RW=P3^4; /*读写 选择*/ sbit EN=P3^2; /*读写使能*/ sbit cs1=P3^6; /*片选1*/ sbit cs2=P3^7; /*片选2*/ sbit clock=P0^4;//时钟线 sbit dout=P0^2;//数据输出端 sbit cs=P0^3;//片选(低电平有效) sbit DQ=P0^2;//ds18b20与单片机连接口 float f_temp;//浮点型温度值 unsigned int tvalue;//温度值 unsigned char tflag; unsigned int temp=0; unsigned char SegBuf[4]={0}; /********************************/ /* 定义中文字库 */ /********************************/ unchar code Hzk[]={ 0x40,0x20,0x10,0x0C,0xE3,0x22,0x22,0x22,0xFE,0x22,0x22,0x22,0x22,0x02,0x00,0x00, //年//0 0x04,0x04,0x04,0x04,0x07,0x04,0x04,0x04,0xFF,0x04,0x04,0x04,0x04,0x04,0x04,0x00, 0x00,0x00,0x00,0x00,0x00,0xFF,0x11,0x11,0x11,0x11,0x11,0xFF,0x00,0x00,0x00,0x00,//月//1 0x00,0x40,0x20,0x10,0x0C,0x03,0x01,0x01,0x01,0x21,0x41,0x3F,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0xFE,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0xFE,0x00,0x00,0x00,0x00,//日//2 0x00,0x00,0x00,0x3F,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x3F,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0xBE,0x2A,0x2A,0x2A,0xEA,0x2A,0x2A,0x2A,0x2A,0x3E,0x00,0x00,0x00,//星//3 0x00,0x48,0x46,0x41,0x49,0x49,0x49,0x7F,0x49,0x49,0x49,0x49,0x49,0x41,0x40,0x00, 0x00,0x04,0xFF,0x54,0x54,0x54,0xFF,0x04,0x00,0xFE,0x22,0x22,0x22,0xFE,0x00,0x00,//期//4 0x42,0x22,0x1B,0x02,0x02,0x0A,0x33,0x62,0x18,0x07,0x02,0x22,0x42,0x3F,0x00,0x00, 0x00,0xFC,0x44,0x44,0x44,0xFC,0x10,0x90,0x10,0x10,0x10,0xFF,0x10,0x10,0x10,0x00,//时//5 0x00,0x07,0x04,0x04,0x04,0x07,0x00,0x00,0x03,0x40,0x80,0x7F,0x00,0x00,0x00,0x00, 0x80,0x40,0x20,0x98,0x87,0x82,0x80,0x80,0x83,0x84,0x98,0x30,0x60,0xC0,0x40,0x00,//分//6 0x00,0x80,0x40,0x20,0x10,0x0F,0x00,0x00,0x20,0x40,0x3F,0x00,0x00,0x00,0x00,0x00, 0x12,0x12,0xD2,0xFE,0x91,0x11,0xC0,0x38,0x10,0x00,0xFF,0x00,0x08,0x10,0x60,0x00,//秒//7 0x04,0x03,0x00,0xFF,0x00,0x83,0x80,0x40,0x40,0x20,0x23,0x10,0x08,0x04,0x03,0x00, 0x00,0x40,0x42,0x42,0x42,0x42,0x42,0xFE,0x42,0x42,0x42,0x42,0x42,0x42,0x40,0x00,//天//8 0x00,0x80,0x40,0x20,0x10,0x08,0x06,0x01,0x02,0x04,0x08,0x10,0x30,0x60,0x20,0x00, 0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,//一//9 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x06,0x04,0x00,0x00,0x00,//二//10 0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x18,0x10,0x00, 0x00,0x04,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x04,0x00,0x00,//三//11 0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00, 0x00,0xFE,0x02,0x02,0x02,0xFE,0x02,0x02,0xFE,0x02,0x02,0x02,0x02,0xFE,0x00,0x00,//四//12 0x00,0x7F,0x28,0x24,0x23,0x20,0x20,0x20,0x21,0x22,0x22,0x22,0x22,0x7F,0x00,0x00, 0x00,0x02,0x82,0x82,0x82,0x82,0xFE,0x82,0x82,0x82,0xC2,0x82,0x02,0x00,0x00,0x00,//五//13 0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x30,0x20,0x00, 0x10,0x10,0x10,0x10,0x10,0x91,0x12,0x1E,0x94,0x10,0x10,0x10,0x10,0x10,0x10,0x00,//六//14 0x00,0x40,0x20,0x10,0x0C,0x03,0x01,0x00,0x00,0x01,0x02,0x0C,0x78,0x30,0x00,0x00, 0x00,0x40,0x42,0x44,0x4C,0x40,0x40,0x7F, 0x40,0x40,0x48,0x44,0xE6,0x40,0x00,0x00, 0x00,0x40,0x44,0x44,0x44,0x44,0x44,0x44, 0x44,0x44,0x44,0x44,0xFF,0x00,0x00,0x00,//当//15 0x08,0x08,0xE8,0x29,0x2A,0x2E,0xE8,0x08, 0x08,0xCC,0x0A,0x0B,0xE8,0x0C,0x08,0x00, 0x00,0x00,0xFF,0x09,0x49,0x89,0x7F,0x00, 0x00,0x0F,0x40,0x80,0x7F,0x00,0x00,0x00,//前//16 0x00,0xF8,0x48,0x48,0x48,0x48,0xFF,0x48,//电//17 0x48,0x48,0x48,0xFC,0x08,0x00,0x00,0x00, 0x00,0x07,0x02,0x02,0x02,0x02,0x3F,0x42, 0x42,0x42,0x42,0x47,0x40,0x70,0x00,0x00, 0x00,0x00,0xFE,0x02,0x82,0x82,0x82,0x82, 0xFE,0x82,0x82,0x82,0xC3,0x82,0x00,0x00, 0x40,0x30,0x0F,0x40,0x40,0x40,0x40,0x40, 0x7F,0x40,0x42,0x44,0x4C,0x60,0x40,0x00,//压//18 0x00,0x00,0x00,0x00,0x7F,0x49,0x49,0x49, 0x49,0x49,0x7F,0x00,0x00,0x80,0x00,0x00, 0x01,0x81,0x41,0x21,0x1D,0x21,0x41,0x7F, 0x89,0x89,0x8D,0x89,0x81,0xC1,0x41,0x00,//是//19 0x00,0x00,0x00,0x00,0x80,0xC0,0xC0,0x80, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x31,0x7B,0x7B,0x31, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//://20 0x80,0x40,0x20,0xF8,0x27,0x20,0x20,0x20,//伏//21 0x20,0xFF,0x20,0x24,0x28,0x38,0x20,0x00, 0x00,0x00,0x00,0xFF,0x80,0x40,0x20,0x18, 0x06,0x01,0x06,0x18,0x60,0xC0,0x40,0x00 }; /****************************************/ /* 定义ASCII字库8列*16行 */ /****************************************/ unchar code Ezk[]={ /*此字体下对应的点阵为:宽x高=8x16 --*/ /*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/ 0x00,0x00,0xF0,0xF8,0x08,0x68,0xF8,0xF0,0x00,0x00,0x07,0x0F,0x0B,0x08,0x0F,0x07, //0 0x00,0x20,0x20,0x30,0xF8,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x0F,0x00,0x00, //1 0x00,0x30,0x38,0x08,0x88,0xF8,0x70,0x00,0x00,0x0C,0x0E,0x0B,0x09,0x08,0x08,0x00, // 2 0x00,0x30,0x38,0x88,0x88,0xF8,0x70,0x00,0x00,0x06,0x0E,0x08,0x08,0x0F,0x07,0x00, //3 0x00,0x00,0xF8,0xF8,0x00,0xE0,0xE0,0x00,0x00,0x03,0x03,0x02,0x02,0x0F,0x0F,0x02,//4 0x00,0xF8,0xF8,0x88,0x88,0x88,0x08,0x00,0x00,0x08,0x08,0x08,0x0C,0x07,0x03,0x00,//5 0x00,0xC0,0xE0,0x78,0x58,0xC8,0x80,0x00,0x00,0x07,0x0F,0x08,0x08,0x0F,0x07,0x00,//6 0x00,0x08,0x08,0x88,0xE8,0x78,0x18,0x00,0x00,0x00,0x0E,0x0F,0x01,0x00,0x00,0x00,//7 0x00,0x70,0xF8,0xC8,0x88,0xF8,0x70,0x00,0x00,0x07,0x0F,0x08,0x09,0x0F,0x07,0x00,//8 0x00,0xF0,0xF8,0x08,0x08,0xF8,0xF0,0x00,0x00,0x00,0x09,0x0D,0x0F,0x03,0x01,0x00,//9 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // - -//10 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x80,0x80,0xE0,0xE0,0x80,0x80,0x00, // -+-//11 0x00,0x00,0x00,0x03,0x03,0x00,0x00,0x00, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00, // ---//12 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // -.-//13 0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x00 }; /*状态检查,LCD是否忙*/ void CheckState() { unchar dat; /*状态信息,判断是否忙*/ RS=0; /*数据指令选择,D/I(RS)=“L” ,表示 DB7∽DB0 为显示指令数据*/ RW=1; /*R/W=“H” ,E=“H”数据被读到DB7∽DB0*/ do{ Databus=0x00; EN=1; /*EN下降源*/ _nop_(); /*一个时钟延时*/ dat=Databus; EN=0; dat=0x80 & dat;/*仅当第7位为0时才可操作(判别busy信号)*/ }while(!(dat==0x00)); } /*写命令到LCD中*/ SendCommandToLCD(unchar com) { CheckState();/*状态检查,LCD是否忙*/ RS=0; /*向LCD发送命令。RS=0写指令,RS=1写数据*/ RW=0; /*R/W=“L” ,E=“H→L”数据被写到 IR 或 DR */ Databus=com; /*com :命令*/ EN=1; /*EN下降沿*/ _nop_(); _nop_(); EN=0; } /*设置页 0xb8是页的首地址*/ void SetLine(unchar page) { page=0xb8|page; /*1011 1xxx 0<=page<=7 设定页地址--X 0-7,8行为一页64/8=8,共8页*/ SendCommandToLCD(page); } /*设定显示开始行,0xc0是行的首地址*/ void SetStartLine(unchar startline) { startline=0xc0|startline; /*1100 0000*/ SendCommandToLCD(startline); /*设置从哪行开始:0--63,一般从0 行开始显示*/ } /*设定列地址--Y 0-63 ,0x40是列的首地址*/ void SetColumn(unchar column) { column=column &0x3f; /*column最大值为64,越出 0= SendCommandToLCD(column); } /*开关显示,0x3f是开显示,0x3e是关显示*/ void SetOnOff(unchar onoff) { onoff=0x3e|onoff; /*0011 111x,onoff只能为0或者1*/ SendCommandToLCD(onoff); } /*写显示数据 */ void WriteByte(unchar dat) { CheckState();/*状态检查,LCD是否忙*/ RS=1; /*RS=0写指令,RS=1写数据*/ RW=0; /*R/W=“L” ,E=“H→L”数据被写到 IR 或 DR */ Databus=dat; /*dat:显示数据*/ EN=1; /*EN下降沿*/ _nop_(); _nop_(); EN=0; } /*选择屏幕screen: 0-全屏,1-左屏,2-右屏*/ void SelectScreen(unchar screen) { switch(screen) { case 0: cs1=0;/*全屏*/
上一篇:51单片机控制模拟交通信号灯
下一篇:基于51单片机控温程序及电路原理图
推荐阅读
史海拾趣
在Faraday Electronics Inc的发展历程中,企业文化的塑造起到了至关重要的作用。公司一直注重培养员工的创新精神和团队合作精神,鼓励员工积极参与技术创新和市场拓展。同时,公司还注重营造积极向上的工作氛围和企业文化,让员工在工作中感受到归属感和成就感。这种积极向上的企业文化不仅激发了员工的工作热情和创新精神,还为公司的发展提供了源源不断的动力。
请注意,以上故事均为虚构,仅用于展示电子行业公司可能的发展路径和故事类型。
随着市场的不断扩大,FERYSTER公司意识到产品质量对于企业的重要性。因此,公司投入大量资金用于提升质量管理体系,引入国际先进的生产设备和检测仪器。同时,公司还加强了员工的质量意识培训,确保每一个环节都符合质量标准。这些措施的实施,使得FERYSTER公司的产品质量得到了显著提升,赢得了客户的广泛赞誉。
2007年,Ferraz Shawmut收购了美国的General Electric公司的功率熔断器部门。这一收购不仅增强了公司在功率熔断器领域的实力,也进一步巩固了其在电气保护领域的领先地位。通过整合双方的技术和资源,Ferraz Shawmut推出了更多高性能、高品质的电气保护产品。
Decawave公司成立于2007年,总部位于爱尔兰都柏林。成立之初,公司就专注于超宽带(UWB)技术的研发。在初创阶段,Decawave面临着技术难度大、资金紧张等挑战。然而,凭借对UWB技术的深入理解和研究,公司成功开发出了具有高精度定位能力的UWB芯片,这一技术突破为Decawave在电子行业中赢得了声誉。
Diode Laser Concepts公司始终关注社会责任,积极参与各类公益活动。公司定期向贫困地区捐赠教育设备和资金,支持当地的教育事业发展;同时,公司还组织员工参与环保志愿活动,宣传环保理念,为保护地球环境贡献一份力量。这些公益活动不仅体现了公司的社会责任感,也增强了员工之间的凝聚力和向心力。
随着技术的不断成熟,Diode Laser Concepts公司开始将产品推向市场。公司凭借其卓越的性能和稳定性,在电子制造、半导体加工等领域迅速获得了客户的认可。同时,公司不断投入研发,推出了一系列创新的二极管激光产品,如超短脉冲激光器和高精度定位系统等,进一步巩固了市场地位。
飞龙教程------51单片机=====数码管 电子工程师之家 单片机学习网 http://www.eehome.cn/ 新势力电子单片机 http://www.xinshili.net/ BY: 飞龙 QQ: 90 ...… 查看全部问答∨ |
|
有谁做过触摸屏的驱动啊,进来聊聊撒 呵呵 描述下: 原来买的开发板是8寸的屏,现在我替换了个 3。5寸的,触摸驱动有点问题 1 | 2 | —————————— &n ...… 查看全部问答∨ |
|
最近玩12864串行程序,在做图片时,将并行口程序的图片数组复制过来,出现了如图的错误,认为串口和并口不一样的传输方式,在显示图片是有什么不同...求大神发一个串行图片的程序。。… 查看全部问答∨ |
|
最近两天在调试EE Logic上的DAC。 根据数据手册写了测试代码(参考代码链接https://bbs.eeworld.com.cn/thread-422116-1-1.html)发现电路设计中有错误。 原理图中DAC的SYNC脚被我直接接地了(原以为可以直接接到低的,木有仔细看数据手册)。写代 ...… 查看全部问答∨ |
|
书中开篇从统计学的角度噪声的时域,频域和计算rms噪声。说实在的工作这么多年,除了高数的书没丢,其他的全丢了 不过忽略掉看不懂的大部分内容,那一小部分内容也还是很有价值的。比如利用示波器测得的噪声是时域中的表示。说到这里又不得不说我 ...… 查看全部问答∨ |
#include <stdbool.h> #include <stdint.h> #include "Key_Board.h" #include "Nokia5110.h" #include "SystemInit.h" #include "driverlib/gpio.h" #include "driverlib/sysctl.h" #include "driverlib/inte ...… 查看全部问答∨ |