12864的程序

时间:2015-08-12 03:06:03
【文件属性】:

文件名称:12864的程序

文件大小:1KB

文件格式:TXT

更新时间:2015-08-12 03:06:03

12864

关于12864的一个程序,是c语言,一个简单小编程,显示字符。适#include #include #define uchar unsigned char #define uint unsigned int uchar code table[]="wang xin shi "; uchar code table1[]="sha zhu "; sbit lcden=P2^2; sbit lcdrs=P2^0; sbit lcdrw=P2^1;sbit LCD_PSB = P2 ^ 3; //串/并方式控制 sbit LCD_RST = P2 ^ 5; //液晶复位端口 void delay(uint z); void write_com(uchar com); uchar num; void write_data(uchar date); void delay(uint z) { uint x,y; for(x=z;x>0;x--) for(y=110;y>0;y--); } void write_com(uchar com) { lcdrw=0; lcdrs=0; P0=com; delay(5); lcden=1; delay(5); lcden=0; } void write_data(uchar date) { lcdrw=0; lcdrs=1; P0=date; delay(5); lcden=1; delay(5); lcden=0; } void init() { LCD_PSB = 1; //并口方式 LCD_RST = 0; //液晶复位 delay(100); LCD_RST = 1; delay(100); write_com(0x30); //扩充指令操作 delay(100); write_com(0x30); //基本指令操作 delay(100); write_com(0x0f); //显示开,关光标 delay(100); write_com(0x06); //光标的移动方向 delay(100); write_com(0x01); //清除LCD的显示内容 delay(100); } void main() { init(); write_com(0x80+0x00); for(num=0;num<12;num++) { write_data(table[num]); delay(20); } write_com(0x88+0x00); for(num=0;num<7;num++) { write_data(table1[num]); delay(20); } /* for(num=0;num<16;num++) { write_com(0x18); delay(20); } */ while(1); }用于51.


网友评论