128*64液晶簡(jiǎn)單單片機(jī)代碼
一個(gè)漢字由16*16個(gè)像素點(diǎn)構(gòu)成。
掃描順序上下,然后到第2列再上下,一次類(lèi)推。
顯示結(jié)果:
參考文獻(xiàn):<<手把手教你學(xué)單片機(jī)c程序設(shè)計(jì)>> 下載地址:http://www.51hei.com/bbs/dpj-22812-1.html
主函數(shù)代碼:
#include
#define uchar unsigned char
#define uint unsigned int
#define dataport P0 //數(shù)據(jù)口
sbit CS1=P2^4; //左顯引腳
sbit CS2=P2^3; //右顯引腳
sbit RST=P2^2; //復(fù)位引腳
sbit rs=P2^7; //數(shù)據(jù)或指令寄存器引腳
sbit rw=P2^6; //讀或?qū)懖僮饕_
sbit en=P2^5; //讀寫(xiě)時(shí)能引腳
void delay(unsigned long v); //延時(shí)
void wcode(uchar c,uchar csl,uchar csr); //寫(xiě)指令
void wdata(uchar c,uchar csl,uchar csr); //寫(xiě)數(shù)據(jù)
void set_startline(uchar i); //設(shè)置起始行
void set_xy(uchar x,uchar y); //設(shè)置X,Y方向
void dison_off(uchar k); //顯示器開(kāi)或關(guān)
void reset();//復(fù)位
void lcd_init(); //顯示器初始化
void lw(uchar x,uchar y,uchar dd); //將數(shù)據(jù)寫(xiě)入左右半屏
void display_hz(uchar xx,uchar yy,uchar n,uchar fb); //顯示漢字函數(shù)
uchar code hz[]; //漢字字摸
#include "12864hh.h" //調(diào)用文件(函數(shù)庫(kù))
void main(void)
{
lcd_init();
delay(1000);
while(1)
{
display_hz(2,0,0,0); //display_hz(顯示列位置,顯示頁(yè)位置,顯示第幾個(gè)漢字,是否反顯);
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,/*"愛(ài)",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, /*機(jī)",4*/
評(píng)論