128*64液晶简单单片机代码
一个汉字由16*16个像素点构成。
扫描顺序上下,然后到第2列再上下,一次类推。
显示结果:
参考文献:<手把手教你学单片机c程序设计>> 下载地址:http://www.51hei.com/bbs/dpj-22812-1.html
主函数代码:
#include
#define uchar unsigned char
#define uint unsigned int
#define dataport P0 //数据口
sbit CS1=P2^4; //左显引脚
sbit CS2=P2^3; //右显引脚
sbit RST=P2^2; //复位引脚
sbit rs=P2^7; //数据或指令寄存器引脚
sbit rw=P2^6; //读或写操作引脚
sbit en=P2^5; //读写时能引脚
void delay(unsigned long v); //延时
void wcode(uchar c,uchar csl,uchar csr); //写指令
void wdata(uchar c,uchar csl,uchar csr); //写数据
void set_startline(uchar i); //设置起始行
void set_xy(uchar x,uchar y); //设置X,Y方向
void dison_off(uchar k); //显示器开或关
void reset();//复位
void lcd_init(); //显示器初始化
void lw(uchar x,uchar y,uchar dd); //将数据写入左右半屏
void display_hz(uchar xx,uchar yy,uchar n,uchar fb); //显示汉字函数
uchar code hz[]; //汉字字摸
#include "12864hh.h" //调用文件(函数库)
void main(void)
{
lcd_init();
delay(1000);
while(1)
{
display_hz(2,0,0,0); //display_hz(显示列位置,显示页位置,显示第几个汉字,是否反显);
display_hz(4,0,1,0);
display_hz(6,0,2,0);
display_hz(8,0,3,0);
display_hz(10,0,4,0);
display_hz(2,4,5,0);
display_hz(4,4,6,0);
display_hz(6,4,7,0);
display_hz(8,4,8,0);
display_hz(10,4,9,0);
}
delay(60000);
}
//---------------------------------------------字形码------------------------------------------------------
uchar code hz[]={
0x20,0x04,0x20,0x04,0x22,0x42,0x22,0x82,0xFE,0x7F,0x21,0x01,0x21,0x01,0x20,0x10,
0x20,0x10,0xFF,0x08,0x20,0x07,0x22,0x1A,0xAC,0x21,0x20,0x40,0x20,0xF0,0x00,0x00,/*"我",0*/
0x00,0x40,0x40,0x20,0xB2,0xA0,0x96,0x90,0x9A,0x4C,0x92,0x47,0xF6,0x2A,0x9A,0x2A,
0x93,0x12,0x91,0x1A,0x99,0x26,0x97,0x22,0x91,0x40,0x90,0xC0,0x30,0x40,0x00,0x00,/*"爱",1*/
0x00,0x08,0x00,0x08,0xF8,0x0B,0x28,0x09,0x29,0x09,0x2E,0x09,0x2A,0x09,0xF8,0xFF,
0x28,0x09,0x2C,0x09,0x2B,0x09,0x2A,0x09,0xF8,0x0B,0x00,0x08,0x00,0x08,0x00,0x00,/*"单",2*/
0x00,0x80,0x00,0x40,0x00,0x30,0xFE,0x0F,0x10,0x01,0x10,0x01,0x10,0x01,0x10,0x01,
0x10,0x01,0x1F,0x01,0x10,0x01,0x10,0xFF,0x10,0x00,0x18,0x00,0x10,0x00,0x00,0x00,/*"片",3*/
0x08,0x04,0x08,0x03,0xC8,0x00,0xFF,0xFF,0x48,0x00,0x88,0x41,0x08,0x30,0x00,0x0C,
0xFE,0x03,0x02,0x00,0x02,0x00,0x02,0x00,0xFE,0x3F,0x00,0x40,0x00,0x78,0x00,0x00, /*机",4*/
0x00,0x00,0x00,0x10,0x04,0x10,0x04,0x10,0x04,0x10,0x04,0x10,0x04,0x10,0x04,0x10,
0x04,0x10,0x04,0x10,0x04,0x10,0x06,0x10,0x04,0x10,0x00,0x18,0x00,0x10,0x00,0x00,/*"二",0*/
0x00,0x04,0x0C,0x04,0x04,0x04,0x55,0x0A,0x55,0x0A,0x55,0x09,0x85,0x2A,0x7F,0xCC,
0x85,0x28,0x55,0x19,0x55,0x09,0x55,0x02,0x05,0x06,0x0C,0x02,0x04,0x02,0x00,0x00,/*"零",1*/
0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,
0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xC0,0x00,0x80,0x00,0x00,0x00,/*"一",2*/
0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,
0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xC0,0x00,0x80,0x00,0x00,0x00,/*"一",3*/
0x40,0x04,0x20,0x04,0x10,0x04,0x0C,0x04,0xE3,0x07,0x22,0x04,0x22,0x04,0x22,0x04,
0xFE,0xFF,0x22,0x04,0x22,0x04,0x22,0x04,0x22,0x04,0x02,0x04,0x00,0x04,0x00,0x00};/*"年",4*/
//---------------------------12864.h-----------函数库------------
void delay(unsigned long v) //延时子函数
{
while(v--);
}
void lcd_busy() //判断是否繁忙函数
{
rs=0;
rw=1;
dataport=0xff;
while(1)
{
en=1;
if(dataport<0x80)break; //并口最高位为1时表示芯片正在工作
en=0;
}
en=0;
}
void wcode(uchar c,uchar csl,uchar csr) //写指令函数
{
CS1=csl; //显示左屏变量
CS2=csr; //显示右屏变量
lcd_busy();
rs=0;
rw=0;
dataport=c;
en=1;
en=0;
}
void wdata(uchar c,uchar csl,uchar csr) //写数据子函数
{
CS1=csl;
CS2=csr;
lcd_busy();
rs=1;
rw=0;
dataport=c;
en=1;
en=0;
}
void l
128*64液晶单片 相关文章:
- 128*64液晶采用“单片机内部显示缓冲“的程序(11-17)
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)