⑴ 求51单片机LCD12864串行显示程序,只用SID口和SCLK口,能显示输出四行中文的,最好写上main函数,谢谢
//LCD12864字库系列(控制器ST7920A),单片机:89S52,晶振:12M,
//串口连接 与 并口连接 ( 串口时 屏蔽 并行模块)
//并行连接方式,P2.0-RS,P2.1-RW,P2.2-E
#include<reg52.h>
#include <intrins.h>
sbit RS=P3^2; //串口时为CS
sbit RW=P3^1; //串口为SID
sbit E=P3^0; //串口为时钟SCLK
sbit stop=P2^2;
sbit PSB=P3^4;
sbit REST=P3^3;
//以下是用<at89x51.h>头文件的定义
/*
#define RS P2_0
#define RW P2_1 //定义引脚
#define E P2_2
#define PSB P2_3
#define REST P2_4
#define Data P1
#include<at89x51.h>
*/
#define BF 0x80 //用于检测LCM状态字中的Busy标识
typedef unsigned int Uint;
typedef unsigned char Uchar;
//字符串例子
//"F1--English",也可以往里面写入汉字码,一个汉字由两个码组成
const Uchar F1English[]={0x46,0x31,0x2d,0x2d,0x45,0x6e,0x67,0x6c,0x69,0x73,0x68,0x00};
const Uchar lengthF1=6; //字符串长度
//汉字,直接可以写入字形
unsigned char code uctech[] = {"有限公司"};
const Uchar lengthCF3=8;
Uchar code TAB1[]={
/*-- 调入了一幅图像:D:\公司的文件\程序图片\未命名11.bmp --*/
/*-- 宽度x高度=128x64 --*/
0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x05,0xAE,0x90,0x00,0x00,0x00,0x00,0x00,
0x95,0x55,0x48,0x80,0x00,0x00,0x00,0x00,
0x2B,0x55,0x00,0x00,0x00,0x00,0x00,0x00,
0xA8,0x00,0x22,0x15,0x20,0x00,0x00,0x00,
0x97,0xFB,0x00,0x00,0x00,0x00,0x00,0x00,
0x45,0x55,0x08,0xA0,0x00,0x00,0x00,0x0A,
0x6F,0xF4,0x00,0x00,0x00,0x00,0x00,0x00,
0xB2,0x80,0x40,0x00,0x04,0x40,0x00,0x00,
0xBA,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
0x4D,0x55,0x15,0x15,0x20,0x00,0x00,0x95,
0xD5,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xE8,0x40,0x40,0x00,0x00,0x00,0x4A,
0xAA,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0x2A,0x00,0x40,0x00,0x00,0x15,
0x54,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFD,0xD0,0xAA,0x01,0x00,0x00,0x25,
0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xB6,0x00,0x10,0x00,0x01,0x4A,
0x49,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFD,0xE8,0x40,0x00,0x00,0x11,
0x00,0x24,0x84,0x00,0x00,0x00,0x00,0x00,
0xAB,0xFF,0xFF,0x55,0x00,0x00,0x00,0x24,
0x02,0x49,0x5E,0xA0,0x00,0x00,0x00,0x00,
0x84,0xBF,0xFF,0xF4,0x88,0x00,0x00,0x00,
0x10,0x05,0xFF,0xF4,0x00,0x00,0x00,0x00,
0x29,0x0B,0xFF,0xFA,0x20,0x00,0x00,0x00,
0x02,0xBF,0xFF,0xFC,0x00,0x00,0x00,0x00,
0x44,0xA0,0x57,0xFD,0x80,0x00,0x00,0x00,
0x08,0x5F,0xFF,0xFF,0x80,0x00,0x00,0x00,
0x91,0x0A,0xAA,0xF6,0x50,0x00,0x00,0x00,
0x41,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,
0x44,0xA0,0x01,0x1B,0x84,0x00,0x00,0x00,
0x26,0xFF,0xFF,0xFF,0x90,0x00,0x00,0x00,
0x11,0x0A,0xAA,0x6D,0x68,0x00,0x00,0x00,
0x0B,0xFB,0xFF,0xEF,0xE0,0x00,0x00,0x00,
0xC4,0xA0,0x01,0x02,0x80,0x00,0x00,0x00,
0x43,0xF1,0xFE,0x63,0xF0,0x00,0x00,0x00,
0x15,0x55,0x54,0x55,0x6A,0x00,0x00,0x00,
0x9F,0xE3,0xFC,0x87,0x38,0x00,0x00,0x00,
0xCA,0xAB,0x91,0x00,0x90,0x00,0x00,0x00,
0x07,0xC1,0xFA,0x2A,0x80,0x00,0x00,0x00,
0x25,0xFF,0xFE,0x95,0x2A,0x00,0x00,0x00,
0x2F,0x13,0xFE,0xFC,0x10,0x00,0x00,0x00,
0x95,0xFF,0xFF,0xC0,0x50,0x00,0x00,0x00,
0x0F,0x41,0xFF,0xF3,0x80,0x00,0x00,0x00,
0x4F,0xFF,0xFF,0xF9,0x2A,0x00,0x00,0x00,
0x9F,0x08,0xFF,0xD4,0x00,0x00,0x00,0x00,
0xB3,0xFF,0xFF,0xFE,0x54,0x80,0x00,0x00,
0x1E,0xA0,0x7F,0xA0,0x00,0x00,0x00,0x00,
0x5F,0xFE,0x7F,0xFE,0xAA,0x00,0x00,0x00,
0x5F,0x57,0xFE,0x00,0x00,0x00,0x00,0x00,
0xAF,0xFD,0x7F,0xFF,0x94,0x80,0x00,0x00,
0x1F,0xFE,0xE8,0x00,0x00,0x00,0x00,0x00,
0x7F,0xFA,0x7F,0x5F,0xCA,0x00,0x00,0x00,
0x3F,0x55,0x00,0x00,0x00,0x00,0x00,0x00,
0xAF,0xF1,0x7F,0xDE,0xF5,0x40,0x00,0x00,
0x1A,0xA0,0x80,0x00,0x00,0x00,0x00,0x00,
0xDF,0xF2,0x3F,0xFC,0xC2,0x00,0x00,0x00,
0x50,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
0x2F,0xFA,0xBF,0xFF,0xF4,0xA0,0x00,0x00,
0x05,0x42,0x00,0x00,0x00,0x00,0x00,0x00,
0x97,0xFE,0x3F,0xFF,0xE3,0x00,0x00,0x00,
0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x68,0xFF,0xDF,0xD5,0x78,0x40,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x07,0x5F,0xFF,0x48,0x02,0x80,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xD0,0xAA,0xF4,0xA0,0xAA,0x40,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x0A,0x45,0x09,0x05,0x11,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xA1,0x28,0xA0,0x00,0x44,0x40,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x08,0x42,0x04,0x52,0x12,0x80,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xA5,0x09,0x51,0x00,0x48,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x50,0x04,0x4A,0x12,0x80,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xAA,0x05,0x50,0x21,0x48,0x20,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x90,0x02,0x84,0x12,0x80,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xD4,0x05,0x48,0x10,0x48,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x81,0x20,0x00,0x02,0x02,0x80,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xA4,0x84,0x92,0x48,0x94,0x40,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x48,0x10,0x00,0x00,0x21,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
//这个是在串口时指令和数据之间的延时
/*
void delay10US(Uchar x)
{
Uchar k;
for(k=0;k<x;k++);
}
*/
const Uchar delay=250; //延时时间常数
static void Wait1ms(void)//延迟1 ms
{
Uchar cnt=0;
while (cnt<delay) cnt++;
}
//延迟n ms
void WaitNms(int n)
{
Uchar i;
for(i=1;i<=n;i++)
Wait1ms();
}
void stopint(void)//中断程序
{
if(stop==0)
while(1);
}
//**************************************************************************//
//以下是并口时才开的
//读忙标志,
void RDBF(void)
{
Uchar temp;
RS=0; // RS=0
RW=1; // RW=1
while(1)
{
P1=0xFF; //数据线为输入
E=1;
temp=P1;
E=0; // E=0
if ((temp&0x80)==0) break;
}
}
//写数据到指令寄存器
void WRCommand(Uchar comm)
{
RDBF();
RW=0;
P1=comm;
E=1;
E=0;
}
//写数据到数据寄存器
void WRData(Uchar TEMP)
{
RDBF();
RS=1;
RW=0;
P1=TEMP;
E=1;
E=0;
stopint();
}
/////////////////////////////////////////////////////////////////////////////////
//以下是串口时开的读写时序
/*void SendByteLCD(Uchar WLCDData)
{
Uchar i;
for(i=0;i<8;i++)
{
if((WLCDData<<i)&0x80)RW=1;
else RW=0;
E=0;
E=1 ;
}
}
SPIWR(Uchar Wdata,Uchar WRS)
{
SendByteLCD(0xf8+(WRS<<1));
SendByteLCD(Wdata&0xf0);
SendByteLCD((Wdata<<4)&0xf0);
}
void WRCommand(Uchar CMD)
{
RS=0;
RS=1;
SPIWR(CMD,0);
delay10US(90);//89S52来模拟串行通信,所以,加上89S52的延时,
}
void WRData(Uchar Data)
{
RS=0;
RS=1;
SPIWR(Data,1);
}
*/
/*******************************************************************/
//初始化LCD-8位接口
void LCDInit(void)
{ // PSB=0; //串口
PSB=1;//并口时选这个,上一行取消
REST=1;
REST=0;
REST=1;
WRCommand(0x30); //基本指令集,8位并行
WRCommand(0x06); //启始点设定:光标右移
WRCommand(0x01); //清除显示DDRAM
WRCommand(0x0C); //显示状态开关:整体显示开,光标显示关,光标显示反白关
WRCommand(0x02); //地址归零
}
//显示数组字符串(显示半宽字型16*8点阵)
void ShowQQChar(Uchar addr,Uchar *english,Uchar count)
{
Uchar i;
WRCommand(addr); //设定DDRAM地址
for(i=0;i<count;)
{
WRData(english[i*2]);
WRData(english[i*2+1]);
i++;
}
}
//显示连续字串(半宽字符)
void ShowNUMChar(Uchar addr,Uchar i,Uchar count)
{
Uchar j;
for(j=0;j<count;)
{
WRCommand(addr); //设定DDRAM地址
WRData(i+j);
j++;
WRData(i+j);
addr++;
j++;
}
}
//自定义字符写入CGRAM
void WRCGRAM(Uchar data1,Uchar data2,Uchar addr)
{
Uchar i;
for(i=0;i<16;)
{
WRCommand(addr+i); //设定CGRAM地址
WRData(data1);
WRData(data1);
i++;
WRCommand(addr+i); //设定CGRAM地址
WRData(data2);
WRData(data2);
i++;
}
}
//显示自定义的字符,并把这个字符填满全屏16*16
void ShowCGChar(Uchar addr,Uchar i)
{
Uchar j;
for(j=0;j<0x20;)
{
WRCommand(addr+j); //设定DDRAM地址
WRData(0x00);
WRData(i);
j++;
}
}
void CLEARGDRAM(void)
{
Uchar j;
Uchar i;
WRCommand(0x34);
WRCommand(0x36);
for(j=0;j<32;j++)
{
WRCommand(0x80+j);
WRCommand(0x80);//X坐标
for(i=0;i<32;i++)//
{
WRData(0x00);
}
}
}
//写入GDRAM 绘图,Y是Y绘图坐标,2个字节一行,CLONG是图形长度,以字节
//为单位;HIGHT是图形高度,TAB是图形数据表.12864M的图形显示是相当于256*32点阵.
//由两屏128*32上下两屏组成,同一行的下屏的头地址紧接上屏的未地址。
//绘图在串口输入时,会比在并口下的输入要慢一些
void WRGDRAM(Uchar Y1,Uchar clong,Uchar hight,Uchar *TAB1)
{
Uint k;
Uchar j;
Uchar i;
WRCommand(0x34);
WRCommand(0x36);
for(j=0;j<hight;j++)//32
{ //先上半屏
WRCommand(Y1+j); //Y总坐标,即第几行
WRCommand(0x80);//X坐标,即横数第几个字节开始写起
for(i=0;i<clong;i++)//
{
WRData(TAB1[clong*j+i]);
}
//后下半屏
for(k=0;k<clong;k++)//
{
WRData(TAB1[clong*(j+hight)+k]);
}
}
}
void menu(void)
{
LCDInit();
ShowNUMChar(0x80,0x01,0x0f);//显示半宽特殊符号
ShowNUMChar(0x90,0x30,0x0f);//显示半宽0~?数字标点
ShowNUMChar(0x88,0x41,0x0f);//显示半宽A~P大写
ShowNUMChar(0x98,0x61,0x0f);//显示半宽a~p小写
WaitNms(250); //等待时间
WaitNms(250); //等待时间
stopint();
WRCommand(0x01); //清除显示DDRAM
WRCGRAM(0xff,0x00,0x40);//写入横
WRCGRAM(0x00,0xff,0x50);//写入横2
WRCGRAM(0xaa,0xaa,0x60);//写入竖
WRCGRAM(0x55,0x55,0x70);//写入竖2
ShowCGChar(0x80,0x00);//显示横并填满
WaitNms(250); //等待时间
WaitNms(250); //等待时间
stopint();
WRCommand(0x01); //清除显示DDRAM
ShowCGChar(0x80,02);//显示横2并填满
WaitNms(250); //等待时间
WaitNms(250); //等待时间
stopint();
WRCommand(0x01); //清除显示DDRAM
ShowCGChar(0x80,04);//显示竖并填满
WaitNms(250); //等待时间
WaitNms(250); //等待时间
stopint();
WRCommand(0x01); //清除显示DDRAM
ShowCGChar(0x80,06);//显示竖2并填满
WaitNms(250); //等待时间
WaitNms(250); //等待时间
stopint();
WRCommand(0x01); //清除显示DDRAM
WRCGRAM(0x00,0x00,0x40);//清CGRAM1
WRCGRAM(0x00,0x00,0x50);//清CGRAM2
WRCGRAM(0xaa,0x55,0x40);//写入点
WRCGRAM(0x55,0xaa,0x50);//写入点2
ShowCGChar(0x80,00);//显示点并填满
WaitNms(250); //等待时间
WaitNms(250); //等待时间
stopint();
WRCommand(0x01); //清除显示DDRAM
ShowCGChar(0x80,02);//显示点2并填满
WaitNms(250); //等待时间
WaitNms(250); //等待时间
stopint();
WRCommand(0x01); //清除显示DDRAM
ShowQQChar(0x80,uctech,lengthCF3);//显示'有限公司',以下共四行
ShowQQChar(0x90,uctech,lengthCF3);
ShowQQChar(0x88,uctech,lengthCF3);
ShowQQChar(0x98,uctech,lengthCF3);
WaitNms(250); //等待时间
WaitNms(250); //等待时间
stopint();
WRCommand(0x01); //清除显示DDRAM
}
void menu2(void)
{ CLEARGDRAM();
WRGDRAM(0x80,16,32,TAB1);
WaitNms(250); //等待时间
WaitNms(250); //等待时间
stopint();
}
//主函数
void main(void)
{
menu();//初始化及半宽字符和点横竖汉字扫描
menu2();//绘图显示
for(;;)
{;}
}
⑵ 怎样用51单片机和led8*8矩阵进行字符汉字显示
8*8也就能显示字符,显示汉字比较吃力。
#include<reg51.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar code Table_of_Digits[]=
{
0x00,0x3e,0x41,0x41,0x41,0x3e,0x00,0x00, //0
0x00,0x00,0x00,0x21,0x7f,0x01,0x00,0x00, //1
0x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00, //2
0x00,0x22,0x49,0x49,0x49,0x36,0x00,0x00, //3
0x00,0x0c,0x14,0x24,0x7f,0x04,0x00,0x00, //4
0x00,0x72,0x51,0x51,0x51,0x4e,0x00,0x00, //5
0x00,0x3e,0x49,0x49,0x49,0x26,0x00,0x00, //6
0x00,0x40,0x40,0x40,0x4f,0x70,0x00,0x00, //7
0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00, //8
0x00,0x32,0x49,0x49,0x49,0x3e,0x00,0x00, //9
0xff,0x81,0x81,0x81,0x81,0x81,0x81,0xff
};
uchar code xdat[8]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
uchar code ydat[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
uchar i=0,j=0,t=0,Num_Index,key,xi,yi;
sbit we1=P1^1;
sbit we2=P1^3;
//主程序
void main()
{
//P1=0x80;
Num_Index=0; //从0 开始显示
TMOD=0x01; //T0 方式0
TH0=(65536-2000)/256; //2ms 定时
TL0=(65536-2000)%256;
IE=0x82;
key=0;
xi=0;
yi=0;
EX0=1;
IT0=1;
TR0=1; //启动T0
while(1);
}
//T0 中断函数
void ext_int0() interrupt 0
{
key++;
key&=0x03;
}
void LED_Screen_Display() interrupt 1
{
TH0=(65536-2000)/256; //2ms 定时
TL0=(65536-2000)%256;
switch(key)
{
case 0:
P0=0xff;
we1=1;
P0=~Table_of_Digits[Num_Index*8+i];
we1=0;
P0=0xff; //输出位码和段码
we2=1;
P0=xdat[i];
we2=0;
if(++i==8) i=0; //每屏一个数字由8 个字节构成
if(++t==250) //每个数字刷新显示一段时间
{
t=0;
if(++Num_Index==10) Num_Index=0; //显示下一个数字
}
break;
case 1:
we1=1;
P0=~xdat[xi];
we1=0;
we2=1;
P0=ydat[yi];
we2=0;
if(++t==250) //每个数字刷新显示一段时间
{
t=0;
yi++;
if(yi>7){yi=0;xi++;}
if(xi>7)xi=0;
}
break;
case 2:
we1=1;
P0=0x00;
we1=0;
P0=0xff; //输出位码和段码
we2=1;
P0=xdat[i];
we2=0;
if(++t==250) //每个数字刷新显示一段时间
{
if(++i==8) i=0; //每屏一个数字由8 个字节构成
t=0;
}
break;
default:
key=0;
i=0;
j=0;
t=0;
xi=0;
yi=0;
Num_Index=0;
we1=1;
P0=0xff;
we1=0;
we2=1;
P1=0x80;
we2=0;
break;
}
}
⑶ 51单片机点阵显示一个汉字
8x8的点阵太小,很难正常显示一个汉字,通常,会使用4个8x8的点阵即16x16的点阵来显示一个汉字。
单片机在通过点阵显示汉字的时候,需要用到如下技术手段:
1、汉字取模
汉字取模,即把汉字对应16x16点阵的图形用16进制数来描述,形成可以用于驱动显示的数据。
例如下图,的汉字“中”
该字的16x16点阵图形中,每行有16个像素,可以编码为2个字节,每8个像素,对应一个字节的高低位,则该字编码的前2个字节为0x01,0x80……,如此,可用32个字节描述汉字的点阵图形。
关于汉字取模有很多开源的软件,你可以搜索下载并使用,将你的程序中所需要使用的汉字,全部处理成字模,再定义到程序中即可。(也可以使用汉字字库芯片,这里就不讨论了)
2、扫描显示
通常,驱动点阵设备时,为了节约单片机的管脚资源,会使用锁存器一类的期间,即锁存器输出端与点阵连接,而输入段由单片机控制,采用行、场扫描或分块行、场扫描的方式驱动,具体你可以搜寻相关资料。
⑷ 51单片机LCD1602汉字
LCD1602只允许显示ASCII字符,汉子不在其中,不能显示。汉子可以使用点阵型的LCD显示,如LCD12864。
⑸ 51单片机怎么用按键控制一个数码管,按一下显示一个数字,顺序显示
1、首先,要把代码写好,点亮数码管。
⑹ 51单片机12864lcd显示汉字
会用1602显示英文,就可以用12864lcd显示汉字,二者区别就在于,显示汉字要送两个字节的代码,其中首个字节的值要大于128,而ASCI码的值均小于128。
汉字的机器码不用计算,编译器会自动编译,例如
unsigned char code table[]={ "我爱单片机"“hello” };
显示时,只要先送显示的首地址即可,然后送数组里的内容即可
write_LCD_command(0x88);//第2 行首地址
for(i=0;i<16;i++)
{
write_LCD_data(tab[i]);
delay(5000);
}
⑺ 求51单片机驱动液晶12864的程序,要求是串口方式。程序里不要有绘图反白之类的,只要能显示汉字就行。
绝对好用的串口程序
sbit SID=P2^1; //12864数据
sbit SCLK=P2^2; //12864时钟
init()
{
write(0,0x30); //8 位接口,基本指令集
write(0,0x0c); //显示打开,光标关,反白关
write(0,0x01); //清屏,将DDRAM的地址计数器归零
delaynms(10);
write(0,0x80); for(i=0;i<16;i++) write(1,datas11[i]);
write(0,0x90); for(i=0;i<16;i++) write(1,datas2[i]);
write(0,0x88); for(i=0;i<16;i++) write(1,datas3[i]);
write(0,0x98); for(i=0;i<16;i++) write(1,datas4[i]);
}
/**********************12864*************************/
void delaynms(unsigned int di) //延时
{
unsigned int da,db;
for(da=0;da<di;da++)
for(db=0;db<10;db++);
}
void sendbyte(unsigned char bbyte) //发送一个字节
{
unsigned char i;
for(i=0;i<8;i++)
{
SID=bbyte&0x80; //取出最高位
SCLK=1;
SCLK=0;
bbyte<<=1; //左移
}
}
void write(bit start, unsigned char ddata) //写指令或数据
{
unsigned char start_data,Hdata,Ldata;
if(start==0) start_data=0xf8; //写指令
else start_data=0xfa; //写数据
Hdata=ddata&0xf0; //取高四位
Ldata=(ddata<<4)&0xf0; //取低四位
sendbyte(start_data); //发送起始信号
delaynms(5); //延时是必须的
sendbyte(Hdata); //发送高四位
delaynms(1); //延时是必须的
sendbyte(Ldata); //发送低四位
delaynms(1); //延时是必须的
}
/*void lcdinit(void) //初始化LCD
{
delaynms(10); //启动等待,等LCM讲入工作状态
//PSB=0; ; //串口驱动模式
// RESET=0; delaynms(1); RESET=1; // 复位LCD
// CS=1;
write(0,0x30); //8 位接口,基本指令集
write(0,0x0c); //显示打开,光标关,反白关
write(0,0x01); //清屏,将DDRAM的地址计数器归零
}*/
⑻ 51单片机编写lcd1602显示程序,第一行显示自己的姓名,第二行显示学号
1、首先我们打开Keil μVision编译器,新建一个工程,然后保存在硬盘上的位置,然后选择Atmel-AT89C51单片机为模型,并启动器添加STARTUP.A51文件,然后在当前目录下新建一个C文件,并将其添加入工作路径。
⑼ 怎么编写单片机——TFT彩屏汉字程序
你现在看到的这两个函数LCD_ShowString()ChineseChar()是你在上层调用的,具体的函数定义你要去看底层是怎么实现的。我先简单介绍下着两个函数
LCD_ShowString(12,60,colors[0],colors[7],"-");应该是讲屏幕上x=12,y=60的地方显示一个“-”字符,字符颜色应该是你定义的colors[0],TFT屏的背景颜色是colors[7],这两个是你函数库自己定义的,可以改。
ChineseChar(20,60,1,colors[0],colors[7],1); //带 这个函数和上面那个函数大致相同,至于为什么会显示“带”,是因为最后那个1,这个程序你应该定义一个数组,在这个数组里面对你所要显示的字全部编码并存在这个数组中,最后你只需用想调用数组下标那样调用这个汉子。
至于你想显示班级、姓名 只需用把班级姓名进行编码就可以调用这个ChineseChar()函数进行显示
其实很简单的,只需用该几步就可以达到你想要的,不难~~
⑽ 用keil51单片机C语言编写程序,使液晶显示器显示16*16点阵汉字,请问怎么编写,谢谢!
#include"at89x51.h"
unsigned char code led[]={0x10,0x04,0x10,0x03,0xD0,
0x00,0xFF,0xFF,0x90,0x00,
0x18,0x1D,0xF7,0x13,0x14,
0x11,0x54,0x15,0x94,0x19,
0x14,0x51,0x14,0x91,0xF6,
0x7F,0x04,0x11,0x00,0x01,
0x00,0x00,
0x04,0x04,0x04,0x02,0x04,
0x01,0xC4,0xFF,0x3F,0x00,
0x04,0x20,0x04,0x10,0x04,
0x08,0xE4,0x3F,0x04,0x42,
0x1F,0x41,0x84,0x40,0xC4,
0x40,0x06,0x40,0x04,0x70,
0x00,0x00};
unsigned char i=0,j=0,time_50ms=0;
delay();
main()
{
TMOD=0X01;
TH0=0X3C;
TL0=0XB0;
TR0=1;
ET0=1;
EA=1;
while(1)
{
P1=i;
P2=led[32*j+2*i];
P3=led[32*j+2*i+1];
delay();
i++;
if(i==16)
i=0;
if(time_50ms==20)
{
time_50ms=0;
j++;
if(j==2)
j=0;
}
}
}
int_T0() interrupt 1
{
TH0=0X3C;
TL0=0XB0;
time_50ms++;
}
delay()
{
unsigned char t1;
for(t1=0;t1<100;t1++);
}