问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

谁有51单片机彩色液晶程序的详解啊???

发布网友 发布时间:2022-04-25 18:29

我来回答

3个回答

热心网友 时间:2023-10-23 18:07

#include "reg52.h"

sbit LED=P1^0;//LED锁存器
sbit SEG=P1^1;//数码管段选锁存器
sbit DIG=P1^2;//数码管位选锁存器
unsigned char t;

sbit LCDRS=P2^7;//数据指令控制
sbit LCDRW=P2^6;//读写控制
sbit LCDEN=P2^5;//液晶屏使能控制

//**********延时函数,延时n*1ms*********
void delay(unsigned char n)
{
int i,j;
for (i=0; i<n; i++)
for (j=0; j<100; j++)
;
}

//*************写命令***************
void Write_Cmd(unsigned char C)
{
LCDEN=1;//使能端,由高电平跳变成低电平时,液晶屏模块执行命令
LCDRS=0;//指令寄存器选择
P0=C;
delay(5);
LCDEN=0;
}

//**************写数据**************
void Write_Data(unsigned char D)
{
LCDEN=1;//使能端,由高电平跳变成低电平时,液晶屏模块执行命令
LCDRS=1;//选择数据寄存器
P0=D;
delay(5);
LCDEN=0;
}

//**********LCD初始化*****************
void LCD_Init()
{
LCDRS=0;//指令寄存器选择
Write_Cmd(0x01);//清屏
Write_Cmd(0x38);//功能设置8位双行显示5*7点阵
Write_Cmd(0x0F);//开关显示设置
Write_Cmd(0x06);//输入方式设置,光标从左向右移动,内容不移动
}

void main()
{
unsigned char Code1[]="I LOVE MCU!";
unsigned char m;

//LED,数码管锁存器片选设置
LED=0;
DUAN=0;
WEI=0;

LCDRW=0;//写选择

LCD_Init();

Write_Cmd(0x80+0x01);//写入显示缓冲区起始地址为1行2列

for(m=0;m<11;m++)
{
Write_Data(Code1[m]);
delay(3);
}

while (1)
;
}//end of main

热心网友 时间:2023-10-23 18:08

可以选用彩屏模块。。。。联系本人
/*------------------------------------------------------------------------------
DEMO.C

Copyright 1995-1999 Keil Software, Inc.
------------------------------------------------------------------------------*/

#include <REG51.H>
#include <stdio.h>
#define uchar unsigned char

#define RED0XF800
#define GREEN0X07E0
#define BLUE0X000F
#define YELLOW0XFFE0
#define WHITE0XFFFF
#define BLACK0X0000

sbit buzy=P1^7;

#define uchar unsigned char

#define HmiIsBusy (buzy==0)

void DelayMs(unsigned int dly )
{
unsigned int a=30;
while(dly--)
{
a=50;
while (a--);
}
}

/*------------------------------------------------
The main C function. Program execution starts
here after stack initialization.
------------------------------------------------*/
void main (void)
{

unsigned int LcdXsize,LcdYsize;
unsigned int temp;
/*------------------------------------------------
Setup the serial port for 9600 baud at 11.0592MHz.
------------------------------------------------*/
SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */
TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */
TH1 = 253; /* TH1: reload value for 9600 baud @ 11.0592MHz */
TR1 = 1; /* TR1: timer 1 run */
TI = 1; /* TI: set TI to send first char of UART */

DelayMs(500);

printf("CLS %d\n",BLACK);
while(!HmiIsBusy);while(HmiIsBusy);

DelayMs(500);

/*------------------------------------------------
Get HMI resolution
------------------------------------------------*/

LcdXsize=0;
LcdYsize=0;

while( (LcdXsize>480)||(LcdXsize<240)||(LcdYsize>480)||(LcdYsize<240))
{
LcdXsize=0;
LcdYsize=0;
RI=0;
printf("SIZE\n");
while(RI!=1);
RI=0;
while(RI!=1);
RI=0;
while(RI!=1);
RI=0;
while(RI!=1);
RI=0;
while(RI!=1);
RI=0;

LcdXsize+=((SBUF-0X30)*100);
while(RI!=1);
RI=0;
LcdXsize+=((SBUF-0X30)*10);

while(RI!=1);
RI=0;

while(RI!=1);
RI=0;

while(RI!=1);
RI=0;
LcdYsize+=((SBUF-0X30)*100);

while(RI!=1);
RI=0;
LcdYsize+=((SBUF-0X30)*10);

while(RI!=1);
RI=0;

DelayMs(50);

}

while(1)
{
/*------------------------------------------------
Display RED GREEN BLUE
------------------------------------------------*/

printf("CLS %d\n",RED);
while(!HmiIsBusy);while(HmiIsBusy);
DelayMs(1000);

printf("CLS %d\n",GREEN);
while(!HmiIsBusy);while(HmiIsBusy);
DelayMs(1000);

printf("CLS 30\n");
while(!HmiIsBusy);while(HmiIsBusy);
DelayMs(1000);

/*------------------------------------------------
Demo1 CIRCLE
------------------------------------------------*/

printf("CLS 0\n");
while(!HmiIsBusy);while(HmiIsBusy);

printf("STR 0 0 %d Demo1\n",WHITE);
while(!HmiIsBusy); while(HmiIsBusy);
printf("STR 0 20 %d CIRCLE\n",WHITE);
while(!HmiIsBusy); while(HmiIsBusy);

printf("CIRCLE %d %d 20 %d \n",LcdXsize/2,LcdYsize/2-15,WHITE);
while(!HmiIsBusy);while(HmiIsBusy);
printf("CIRCLE %d %d 21 %d \n",LcdXsize/2,LcdYsize/2-15,WHITE);
while(!HmiIsBusy);while(HmiIsBusy);

printf("CIRCLE %d %d 20 31 \n",LcdXsize/2-50,LcdYsize/2-15);
while(!HmiIsBusy); while(HmiIsBusy);
printf("CIRCLE %d %d 21 31 \n",LcdXsize/2-50,LcdYsize/2-15);
while(!HmiIsBusy); while(HmiIsBusy);

printf("CIRCLE %d %d 20 %d \n",LcdXsize/2+50,LcdYsize/2-15,RED);
while(!HmiIsBusy); while(HmiIsBusy);
printf("CIRCLE %d %d 21 %d \n",LcdXsize/2+50,LcdYsize/2-15,RED);
while(!HmiIsBusy); while(HmiIsBusy);

printf("CIRCLE %d %d 20 %d \n",LcdXsize/2-25,LcdYsize/2+8,YELLOW);
while(!HmiIsBusy); while(HmiIsBusy);
printf("CIRCLE %d %d 21 %d \n",LcdXsize/2-25,LcdYsize/2+8,YELLOW);
while(!HmiIsBusy); while(HmiIsBusy);

printf("CIRCLE %d %d 20 %d \n",LcdXsize/2+25,LcdYsize/2+8,GREEN);
while(!HmiIsBusy); while(HmiIsBusy);
printf("CIRCLE %d %d 21 %d \n",LcdXsize/2+25,LcdYsize/2+8,GREEN);
while(!HmiIsBusy); while(HmiIsBusy);

/*------------------------------------------------
Demo2 LINE AND RECTANGLE
------------------------------------------------*/

DelayMs(3000);
printf("CLS 0\n");
while(!HmiIsBusy); while(HmiIsBusy);

printf("STR 0 0 %d Demo2\n",WHITE);
while(!HmiIsBusy); while(HmiIsBusy);
printf("STR 0 20 %d LINE AND RECTANGLE\n",WHITE);
while(!HmiIsBusy); while(HmiIsBusy);

printf("RECT %d %d %d %d 31\n",LcdXsize*2/10,LcdYsize*2/10,LcdXsize*8/10,LcdYsize*8/10);
while(!HmiIsBusy); while(HmiIsBusy);
printf("RECT %d %d %d %d %d\n",LcdXsize*3/10,LcdYsize*3/10,LcdXsize*7/10,LcdYsize*7/10,GREEN);
while(!HmiIsBusy); while(HmiIsBusy);
printf("RECT %d %d %d %d %d\n",LcdXsize*4/10,LcdYsize*4/10,LcdXsize*6/10,LcdYsize*6/10,RED);
while(!HmiIsBusy); while(HmiIsBusy);

printf("LINE %d %d %d %d %d\n",LcdXsize*2/10,LcdYsize*2/10,LcdXsize*8/10,LcdYsize*8/10,YELLOW);
while(!HmiIsBusy); while(HmiIsBusy);

printf("LINE %d %d %d %d %d\n",LcdXsize*8/10,LcdYsize*2/10,LcdXsize*2/10,LcdYsize*8/10,YELLOW);
while(!HmiIsBusy); while(HmiIsBusy);

/*------------------------------------------------
Demo3 DISPLAY PICTURE
------------------------------------------------*/

DelayMs(3000);
printf("CLS 0\n");
while(!HmiIsBusy); while(HmiIsBusy);

printf("STR 0 0 %d Demo3\n",WHITE);
while(!HmiIsBusy); while(HmiIsBusy);
printf("STR 0 20 %d PICTURE\n",WHITE);
while(!HmiIsBusy); while(HmiIsBusy);

printf("PIC 2 0 40\n");
while(!HmiIsBusy); while(HmiIsBusy);

DelayMs(1000);

printf("PIC 3 0 40\n");
while(!HmiIsBusy); while(HmiIsBusy);

/*------------------------------------------------
Demo4 CUT A SMALL PICTURE FROM BIG PICTURE
------------------------------------------------*/

DelayMs(3000);
printf("CLS 0\n");
while(!HmiIsBusy); while(HmiIsBusy);

printf("STR 0 0 %d Demo4\n",WHITE);
while(!HmiIsBusy); while(HmiIsBusy);
printf("STR 0 20 %d CUT PICTURE\n",WHITE);
while(!HmiIsBusy); while(HmiIsBusy);

for(temp=0;temp<30;temp++)
{
printf("CUT 4 %d %d %d %d 128 128\n",LcdXsize/2-64,LcdYsize/2-64,temp,temp);
while(!HmiIsBusy); while(HmiIsBusy);
}

for(temp=30;temp>0;temp--)
{
printf("CUT 4 %d %d %d %d 128 128\n",LcdXsize/2-64,LcdYsize/2-64,temp,temp);
while(!HmiIsBusy);while(HmiIsBusy);
}

/*------------------------------------------------
Demo5 MOTION PICTURE
------------------------------------------------*/

DelayMs(3000);
printf("CLS 0\n");
while(!HmiIsBusy); while(HmiIsBusy);

printf("STR 0 0 %d Demo5\n",WHITE);
while(!HmiIsBusy); while(HmiIsBusy);
printf("STR 0 20 %d MOTION\n",WHITE);
while(!HmiIsBusy); while(HmiIsBusy);

if(((LcdXsize==320)&&(LcdYsize==240))||((LcdXsize==240)&&(LcdYsize==320)))
{
printf("MOT 0 40 10 15 10 \n");
while(!HmiIsBusy); while(HmiIsBusy);
}
if(((LcdXsize==400)&&(LcdYsize==240))||((LcdXsize==240)&&(LcdYsize==400)))
{
printf("MOT 0 40 8 13 10 \n");
while(!HmiIsBusy); while(HmiIsBusy);
}
if(((LcdXsize==320)&&(LcdYsize==480))||((LcdXsize==480)&&(LcdYsize==320)))
{
printf("MOT 0 40 5 10 10 \n");
while(!HmiIsBusy); while(HmiIsBusy);
}
/*------------------------------------------------
END OF DEMO
------------------------------------------------*/

DelayMs(7000);
printf("MOFF\n");
DelayMs(100);
printf("CLS 0\n");
while(!HmiIsBusy); while(HmiIsBusy);

printf("STR %d %d %d Demo Finished!\n",(LcdXsize-14*8)/2,LcdYsize/2-64,RED);
while(!HmiIsBusy); while(HmiIsBusy);
printf("STR %d %d %d Welcom to Use M7-TFT HMI!\n",(LcdXsize-24*8)/2,LcdYsize/2,RED);
while(!HmiIsBusy); while(HmiIsBusy);
printf("STR %d %d 31 Contact us: mcucool@163.com\n",(LcdXsize-27*8)/2,(LcdYsize-20));
while(!HmiIsBusy); while(HmiIsBusy);
DelayMs(8000);

}

while(1);

}

//END

热心网友 时间:2023-10-23 18:08

(武汉谷鑫科技)专业从事单片机驱动彩色液晶显示屏,欢迎到网站上下载资料阅览。各种例程详细。
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
橙子冷藏能保存多久 橙子会过期吗 新鲜橙子如何保存更久 橙子保鲜剂对人体有害吗 粒上皇开口熟栗120g*5袋(共600g)-详细介绍 三皇王板栗介绍 品牌榜:2024年板栗十大品牌排行榜 投票结果公布【新】 为什么来大姨妈胸会胀 少儿学什么舞蹈 青年学什么舞蹈好 51单片机连接LCD 51单片机LCD显示 鸿蒙系统怎么读取u盘,华为Mate20? 怎么能让电脑读取U盘系统 求51单片机程序 51单片机水滴 51单片机怎么休眠 单片机液位控制 怎么用1.5v的电池给51单片机供电(单片机上有液晶)? 51单片机的 怎么学 最快 深入学习51单片机 51单片机该怎么学? 我想用51系列单片机显示水压,谁能帮帮我 在下想做一个基于51单片机的液位监测系统。但情况比较特殊在下又才疏学浅,故来请教各位高手。 51单片机连接两个液位传感器需要一块还是两块AD转换器 基于51单片机的红外感应泵液器的设计 基于mcs-51单片机的液位控制电路设计 编写51单片机实现液晶上字的循环显示和移动程序? 如何用51单片机控制控制水泵,使水箱里的液位达到预定高度。 51单片机字符液晶屏(LMC1602)输出端RS,RW还有E分别都有什么作用? 51单片机液晶高手进 51单片机驱动1602 程序 DS18B20 与51单片机 怎么用 ? 51单片机温度传感器ds18b20、lcd1602液晶C程序 奥尔良鸡丁的做法,奥尔良鸡丁怎么做好吃,奥尔 有没有功能强大的PDF编辑器,要能编辑文字,图片,表格的,最好是中文的? pdf格式的图片怎么编辑要用什么软件才能编辑 用什么软件能修改PDF图片 有什么pdf阅读软件可以直接修改图片内容呢 把图片转换成PDF,用什么软件可以编辑转好的PDF文件? 用什么软件可以编辑PDF里的矢量图最好的,图片都是些油路或电路图的图片... 由图片生成的PDF怎样可以修改呢,用什么软件呢? 红酒浇花的正确方法是什么? 图片格式的PDF文件直接转换成可编辑的文件的软件 变质的自酿葡萄酒可以用来浇花吗 iphonex国行什么时候上市? 电脑机械硬盘无法读取 微信公众平台误删素材怎么恢复? 汽车后备箱加装尾翼打了孔,现在要拆尾翼,打的那个孔怎么处理? 高尔夫6原装尾翼打孔后怎么恢复原貌?