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

单片机彩色液晶屏的使用方法

发布网友 发布时间:2022-04-22 15:36

我来回答

3个回答

热心网友 时间:2023-06-25 23:49

#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-06-25 23:49

可以选用彩屏模块。。。。联系本人
/*------------------------------------------------------------------------------
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-06-25 23:50

(武汉谷鑫科技)专业从事单片机驱动彩色液晶显示屏,欢迎到网站上下载资料阅览。各种例程详细。
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
河南13岁女孩喝农药中毒,是百草枯还是敌草快? 晚上失眠,死活睡不着的时候,你会做什么? 在失眠的时候,你都会做什么? 厘米秀飞船宠物在宠物工作时为什么不能切换其他的宠物进行升级和喂食... 喝中药胃很难受为什么不会想? 一喝中药胃就难受为什么啊 喝中药二十天了胃难受什么原因 戒不掉手淫怎么办,现在脑子里经常全是欲望 我经常手淫想戒但怎么也戒不掉该怎么办 但我每当想手淫的时候怎么也控制不住? 谁能告诉我一个 交友聊天群? 用C51单片机控制液位一般需要那些元件? 基于单片机的水塔水位控制中的水位检测传感器,应该怎样做呢?或者应选择那样的水位传感器呢? AT89c52单片机液晶显示(1602为例)显示一行字 adr是什么词性? 单片机液晶显示RW和RS引脚与LED灯的P1^0和P1^1重合,应该怎么写程序才能让显示屏工作而LED灯不工作呢? 单片机液晶字模生成程序的用法 单片机液晶控制,关于直接访问和间接访问 单片机液晶屏程序求修改 404 Not Found 单片机液晶汉字显示的一个小问题(欢迎!) 基于单片机的液体点滴速度检测装置设计原理图 单片机控制液晶屏显示 单片机 液晶显示温度 程序 用C51单片机控制液位一般需要那些元件? 基于单片机的液位检测系统的设计与制作 单片机液位检测系统设计 单片机液位计课程设计怎么做? 关于喝水减肥... ... 多喝水会变瘦,是真的么? 为什么我的的单片机液晶显示屏一连上nrf24l01就发热 为什么在做单片机实验中的液晶显示时要清屏 离婚交友群有吗? 404 Not Found 他趣发对方收不到吗 男孩名取名为严怡霖,好吗咋么解释这个名字? 手机相册怎样设置壁纸? 邵怡霖名字测试结果 中文是怡霖,取个有意义的英文名 鎴戝彨浠箞锡嶅瓧锛这些字汉语拼音怎么写,什么意思 起名字 求一女孩名字? 给女儿取个好名字我姓农 离婚交友群有吗? 谁帮忙起个好听的名字? 姓高,名字中间有&quot;怡&quot;字!取什么名字好? 苹果 6通话记录怎么可以保存很长时间? 男孩男孩男孩怡霖的妹妹叫什么好 苹果手机未接电话保存多久 他趣发对方收不到吗 苹果手机怎么把短信和通话记录保存久一些?