12864 LCD图形显示程序例子

发布者:jiaohe1最新更新时间:2016-11-03 来源: eefocus关键字:LCD  图形显示 手机看文章 扫描二维码
随时随地手机看文章
#include "pic.h" 
#define RS RC0 
#define RW RC1 
#define E RC2 
#define PSB RC3 
#define RST RC4 
//PORTD=DATA; 
unsigned char COUNT3,COUNT2,COUNT1,COUNT,LCD_X,LCD_Y,LCD_DATA1,LCD_DATA2,LCD_DATA,F3,R1,F0;
const unsigned char TU_TAB1[]={ 
// 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xF0,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x18,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xBF,0xFF,0xDC,0x00,0x01, 
0x80,0x00,0x1F,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0xBF,0xFF,0xBC,0x00,0x01, 
0x80,0x00,0x30,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x01,0x7F,0xFF,0xB8,0x00,0x01, 
0x80,0x00,0x30,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x01,0x7F,0xFF,0x78,0x00,0x01, 
0x80,0x00,0x19,0xFF,0xFE,0xC0,0x00,0x00,0x00,0x00,0x02,0xFF,0xFF,0x70,0x00,0x01, 
0x80,0x00,0x18,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x02,0xFF,0xFE,0xF0,0x00,0x01, 
0x80,0x00,0x0C,0x01,0xFF,0x60,0x00,0x00,0x00,0x00,0x05,0xFF,0xFE,0xE0,0x00,0x01, 
0x80,0x00,0x0C,0x7F,0xD0,0x20,0x00,0x00,0x00,0x00,0x05,0xFF,0xFD,0xE0,0x00,0x01, 
0x80,0x00,0x06,0x00,0x0F,0xB0,0x00,0x00,0x00,0x00,0x0B,0xFF,0xFD,0xC0,0x00,0x01, 
0x80,0x00,0x06,0x03,0xFC,0x10,0x00,0x00,0x00,0x00,0x0B,0xFF,0xFB,0xC0,0x00,0x01, 
0x80,0x00,0x03,0x1F,0x00,0x18,0x00,0x00,0x00,0x00,0x17,0xFF,0xFB,0x80,0x00,0x01, 
0x80,0x00,0x03,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x17,0xFF,0xF7,0x80,0x00,0x01, 
0x80,0x00,0x01,0x80,0x00,0x0C,0x00,0x00,0x00,0x00,0x17,0xFF,0xF7,0x00,0x00,0x01, 
0x80,0x00,0x01,0x80,0x00,0x04,0x00,0x00,0x00,0x00,0x09,0xFF,0xEF,0x00,0x00,0x01, 
0x80,0x00,0x00,0xC0,0x00,0xF6,0x00,0x00,0x00,0x00,0x06,0x7F,0xEE,0x00,0x00,0x01, 
0x80,0x00,0x00,0xC0,0x03,0xC2,0x00,0x00,0x00,0x00,0x01,0x9F,0xDE,0x00,0x00,0x01, 
0x80,0x00,0x00,0x60,0x00,0x3B,0x00,0x00,0x00,0x00,0x00,0x67,0xDF,0x00,0x00,0x01, 
0x80,0x00,0x00,0x60,0x00,0xE3,0x00,0x00,0x00,0x00,0x00,0x19,0xBF,0x00,0x00,0x01, 
0x80,0x00,0x00,0x30,0x03,0x8E,0x00,0x00,0x00,0x00,0x00,0x06,0x3F,0x00,0x00,0x01, 
0x80,0x00,0x00,0x30,0x06,0x3C,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0x00,0x00,0x01, 
0x80,0x00,0x00,0x18,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x01, 
0x80,0x00,0x00,0x18,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x0F,0x7F,0x80,0x00,0x01, 
0x80,0x00,0x00,0x0C,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x1F,0xC0,0x00,0x01, 
0x80,0x00,0x00,0x0C,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x07,0xE0,0x00,0x01, 
0x80,0x00,0x00,0x06,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x1F,0xE0,0x00,0x01, 
0x80,0x00,0x00,0x07,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x3F,0xC0,0x00,0x01, 
0x80,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0xFF,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFC,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xF0,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xC0,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x05,0x40,0x88,0x04,0x01,0x08,0x00,0x00,0x0A,0x81,0x10,0x04,0x00,0x20,0x01, 
0x80,0x79,0x21,0x08,0x02,0x21,0x49,0x00,0x00,0xF2,0x42,0x10,0x04,0x47,0x10,0x01, 
0x80,0x09,0x07,0xDF,0x7F,0xF7,0xAA,0x00,0x00,0x12,0x0F,0xBE,0x7F,0xE5,0xFE,0x01, 
0x80,0x7F,0xF4,0x51,0x08,0x81,0x2C,0x00,0x00,0xFF,0xE8,0xA2,0x44,0x47,0x00,0x01, 
0x80,0x09,0x04,0x61,0x08,0x81,0x7F,0x00,0x00,0x12,0x08,0xC2,0x7F,0xC5,0x4A,0x01, 
0x80,0x0B,0x24,0x51,0x08,0x83,0x81,0x00,0x00,0x16,0x48,0xA2,0x44,0x45,0x6A,0x01, 
0x80,0x1D,0x47,0xC9,0x05,0x05,0x01,0x00,0x00,0x3A,0x8F,0x92,0x44,0x47,0x52,0x01, 
0x80,0x68,0x84,0x49,0x05,0x05,0x7F,0x00,0x00,0xD1,0x08,0x92,0x7F,0xC5,0x6A,0x01, 
0x80,0x09,0x94,0x41,0x02,0x01,0x01,0x00,0x00,0x13,0x28,0x82,0x44,0x05,0x4A,0x01, 
0x80,0x0E,0x57,0xC1,0x0D,0x81,0x01,0x00,0x00,0x1C,0xAF,0x82,0x04,0x29,0x42,0x01, 
0x80,0x38,0x34,0x4E,0x70,0x71,0x7F,0x00,0x00,0x70,0x68,0x9C,0x03,0xEB,0x7E,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF 
}; 

//*************delay_ms******************************** 
void delay_10us(unsigned char x) 

while(x--); 

void delay_ms(unsigned char cnt) 

unsigned char i; 
do { 
i = 4; 
do { 
delay_10us(39); 
} while(--i); 
} while(--cnt); 


//***********检查是否LCD忙碌的子程序********************** 
void check_busy(void) 

TRISD=0xff;//在此处设为输入。 
PORTD=0xff; 
RS=0; 
RW=1; 
while (1) 

NOP();NOP();NOP(); 
E =1; 
NOP();NOP();NOP(); 
if (RD7==0) break; 
NOP();NOP();NOP(); 
E =0; 

E =0; 
TRISD=0X00;//还原为输出。 
RC7=!RC7; 
//delay_ms(50); 

//**********数据写命令*************************** 
void send_com(unsigned char command ) 

check_busy(); 
RS=0; 
RW=0; 
PORTD=command; 
E =1; 
NOP(); 
NOP(); 
E =0; 

//**********LCD初始化时的送命令****************** 
void send_com_init(unsigned char command_init ) 

RS=0; 
RW=0; 
PORTD=command_init; 
E =1; 
NOP(); 
NOP(); 
E =0; 

//**********写数据*************************** 
void send_data(unsigned char data ) 

check_busy(); 
RS=1; 
RW=0; 
PORTD=data; 
E =1; 
NOP(); 
NOP(); 
E =0; 

//***********读数据**************************** 
unsigned char read_data(void) 

unsigned char read_data; 
check_busy(); 
TRISD=0XFF; 
RS=1; 
RW=1; 
E =1; 
NOP(); 
read_data=PORTD; 
E =0; 
TRISD=0x00;//还原为输出。 
return (read_data); 

//***********清屏***************************** 
void clear_LCD(void) 

send_com(0x01); 
send_com(0x34); 
send_com(0x30); 

//**********LCD初始化************************ 
void initial_LCD(void) 

PSB=1; 
RST=0;//Reset. 
NOP(); 
NOP(); 
RST=1; 
NOP(); 
delay_10us(10); 
send_com_init(0x30);//30H--基本指令操作 
delay_10us(4); 
send_com_init(0x0c);//开显示,关光标,不闪烁。 
delay_10us(10); 
send_com_init(0x01);//清除显示 
delay_ms(10); 
send_com_init(0x06);//指定在资料写入或读取时,光标的移动方向,DDRAM的地址计数器(AC)加1。


//**********写准备*************************** 
void WR_ZB(void) 

send_com(0x34); 
send_com(LCD_Y); 
send_com(LCD_X); 
send_com(0x30); 

//*********取数送显示****************************** 
void QUSHU(const unsigned char *shu) 

for (;COUNT!=0;COUNT--) 

send_data(*shu++); 
delay_ms(80); 


//*********Flash****************************** 
void flash(void) 

send_com(0x08);//关闭显示 
delay_ms(250); 
send_com(0x0c);//开显示,关光标,不闪烁。 
delay_ms(250); 
send_com(0x08);//关闭显示 
delay_ms(250); 
send_com(0x0c);//开显示,关光标,不闪烁。 
delay_ms(250); 
send_com(0x08);//关闭显示 
delay_ms(250); 

//**********显示图形子程序********************* 
void PHO_DISP(const unsigned char *s) 

COUNT3=0X02; 
LCD_X=0X80; 
for (;COUNT3!=0;COUNT3--) 

LCD_Y=0X80; 
COUNT2=0X20;//32 
for (;COUNT2!=0;COUNT2--) 

COUNT1=0X10;//16 
WR_ZB(); 
for (;COUNT1!=0;COUNT1--) 

send_data(*s++); 


LCD_Y+=1; 

LCD_X=0X88; 

send_com(0x36); 
send_com(0x30); 

//******************显示点阵子程序************ 
void LAT_DISP(void) 

COUNT3=0X02; 
LCD_X=0X80; 
for (;COUNT3!=0;COUNT--) 

LCD_Y=0X80; 
F0=0; 
COUNT2=0X20; 
for (;COUNT2!=0;COUNT--) 

COUNT1=0X10; 
WR_ZB(); 
if (F0!=0) 

LCD_DATA=LCD_DATA2; 

else LCD_DATA=LCD_DATA1; 
for (;COUNT1!=0;COUNT1--) 

send_data(LCD_DATA); 

LCD_Y+=1; 
F0=!F0; 

LCD_X=0X88; 


send_com(0x36); 
send_com(0x30); 


void main(void) 

TRISC=0X00; 
TRISD=0X00; 
PORTD=0X00; 
PORTC=0X00; 
initial_LCD(); 
while (1) 

clear_LCD(); 
PHO_DISP(TU_TAB1);//显示图形 
while (1); 

}
关键字:LCD  图形显示 引用地址:12864 LCD图形显示程序例子

上一篇:基于PIC16F877的四位数码管动态显示PROTEUS仿真
下一篇:PIC单片机ADC的简单应用

推荐阅读最新更新时间:2024-03-16 15:19

ARM微控制器LPC210X的LCD接口技术
摘要:本文分别以GPI0口直接连接、串行转换连接、CPLD分部连接三种方法阐述了无外部总线的Philips ARM微控制器LPC210X与点阵图形液晶显示器的接口设计,并给出硬件电路框图和主要程序。 关键词:ARM LPC210X LCD接口 串并转换 CPLD 引言 Philips最近推出了其第一款基于ARM内核的控制器LPC210X,但由于LPC210X外部总线不开放,无法扩展内存、驱动液晶显示器等,给它的推广带来了一定的影响。笔者最近在一工控板项目中采用了该系列芯片,项目后斯应客户要求需对几个参量进行显示并扩展键盘,不得已之下,采用了CPLD,并利用了GPIO口模拟总线和液晶时序与点阵图形液日模块HS12864-16建
[嵌入式]
单片机波形发生器源码
程序源码 #include reg51.h #include intrins.h #include math.h #define uchar unsigned char #define uint unsigned int unsigned long Result,i; sbit SDA=P1^1; //PCF8591 接口 sbit SCL=P1^0; unsigned int a=0; // 波形采样点值 unsigned int b=0; unsigned int c=0; unsigned int bx_chang=0; unsigned int n=40; // 频率计算值 unsigned c
[单片机]
单片机波形发生器源码
vivo T1 5G或登陆印度:骁龙695+6.58吋LCD屏+5000mAh电池
vivo 已敲定于 2 月 9 日在印度市场发布 T1 5G 手机。在正式发布之前,该机的规格、外观等信息均已曝光。根据爆料人士 Ishan Agarwal(@ishanagarwal24)分享的真机谍照,该机背面采用斑点状的柔和色彩图案,机身正面配备水滴状的刘海区域。   另一位爆料人士 Mukul Sharma(@stufflistings)分享了 T1 5G 的拍摄样张。Mukul 在推文中表示:“撇开性能不谈,单从相机功能来看,它将会是一个超级棒的设备”。   据悉,vivo T1 5G 和目前国内已经上市发售的 T1 和 T1x 都不相同,该机采用比后两者更低端的芯片组--骁龙 695。T1 5G的其他规格包括6.
[手机便携]
LCD TV中的电源应用方案
  LCD TV电源架构的介绍   图1所示为LCD TV的电源架构,图中架构的输入电压为90-265V,输入频率从47Hz到63Hz,经过调试整流后会经过PFC架构,由于本文主要针对MOS,因此图中没有表示出调试整流部分。PFC根据所使用的IC选择采用DCM或者CCM。从PFC出来后有一个PWM,如果输出功率小于65W,则PWM端采用Flyback或QR模式。现在LCD TV常用的是半桥共振和LLC架构。5V一侧有备用电源,目前LCD TV的备用电源通常采用的是IC绑定MOS。所不同的是逆变器部分,传统输出是24V,此处采用的则是LIPS架构,并从PFC端将400V电压直接加到此处。电压从24V增加到400V的好处是:电流相对变
[电源管理]
<font color='red'>LCD</font> TV中的电源应用方案
富士康投100亿美元在美国建LCD工厂 图啥?
富士康要在美国建厂,小编开始以为只是普通的一句话,考虑到诸多现实问题之后会放弃这种想法,然而如今成了现实,富士康逃到美国到底图啥呢?下面就随嵌入式小编一起来了解一下相关内容吧。 图片来源:视觉中国 富士康最终还是跑了。美国总统唐纳德·特朗普(Donald Trump)7月26日宣布,富士康计划在威斯康星州建设一家新工厂,履行其在美国投资的承诺。富士康将投资100亿美元,建的是一家新的LCD(液晶显示器)工厂。 据说,这将是有史以来外资公司在美国最大的一笔新建投资,不过它只是富士康在美国诸多投资计划中的首个,未来还会有更多,为威斯康星州创造3,000个全新的工作岗位,并有机会上探至13,000人规模。川普对郭台铭颇为满意:“在
[嵌入式]
单片机引脚直接驱动LCD
LED数码管的驱动是比较简单也容易理解的,多位数码管一般是LED阵列的形式,每个数字使用一个公共端,不同数字的对应同笔段使用一个控制端;驱动采用分时扫描没个数字位,动态显示。但是LED比较费电,我想做一个用电池供电的钟,用发光管电池就撑不了多久了。于是我考虑用液晶。 在这边的电子市场我买到一个4位笔段式液晶屏,4个数字最中间有冒号,边上还有几个箭头符号,一共有15个引脚,正合适用AVR来驱动做一个钟。 笔段式LCD屏的结构与LED数码管很相似,但是由于是液晶,工作机理上不同,驱动方式也有很大差异: (1) LED有正负之分,液晶笔划没有。 (2) LED在直流电压下工作,液晶需
[单片机]
单片机引脚直接驱动<font color='red'>LCD</font>
MSP430f5529——点阵LCD测试小程序
#include msp430.h #include HAL_Buttons.h #include HAL_Board.h #include HAL_Dogs102x6.h void main(void) { uint8_t contrast ; uint8_t brightness ; WDTCTL = WDTPW + WDTHOLD; //关闭看门狗 Dogs102x6_init(); //初始化LCD Dogs102x6_backlightInit(); //背光初始化 contrast = 11; brightness = 11; Dogs102x6_setBacklight(brightness); //设置初始背光
[单片机]
在P87LPC764单片机I2C总线系统中扩展LCD显示
1 引言 I2C总线是Philips公司推出的芯片间串行传输总线。它仅用串行数据线(SDA)和串行时钟线(SCL)两根连线便实现了完善的全双工同步数据传送,并可很方便地构成多机系统和外围器件扩展系统。    本文介绍在P87LPC764单片机中利用I2C总线系统中典型的LCD驱动控制器件PCF8577C来扩展256段静态LCD的电路设计方法。 2 硬件电路设计 2.1 P87LPC764单片机的I2C总线接口 P87LPC764是Philips公司生产的一种小封装、低成本、高性能的单片机(具体内容见参考文献2)。它采用80C51加速处理器结构,片内带有支持I2C总线的硬件接口。当激活I2C总线时,P87LPC764端
[单片机]
在P87LPC764单片机I2C总线系统中扩展<font color='red'>LCD</font><font color='red'>显示</font>器
小广播
添点儿料...
无论热点新闻、行业分析、技术干货……
设计资源 培训 开发板 精华推荐

最新单片机文章
何立民专栏 单片机及嵌入式宝典

北京航空航天大学教授,20余年来致力于单片机与嵌入式系统推广工作。

换一换 更多 相关热搜器件
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved