毕设开源 单片机液晶滚动显示(AT89C51、LCD1602)

单片机液晶滚动显示(AT89C51、LCD1602)

一、简介

此电路由AT89C51最小系统和LCD1602液晶模块组成。可实现上线垂直滚动、左右滚动和播放暂停。

二、执行效果

上下滚动
在这里插入图片描述
左右滚动
在这里插入图片描述
在这里插入图片描述

三、代码


#include 
#include 
#define uchar unsigned char
#define uint unsigned int
void Initialize_LCD();
void ShowString(uchar,uchar,uchar *);
sbit K1 = P3^0;
sbit K2 = P3^1;
sbit K3 = P3^2;

uchar code Prompt[]="PRESS K1--K4 TO START DEMO PROG";
uchar const Line_Count = 6;
uchar code Msg[][80]=
{
 	"Many CAD users dismiss",
	"process of creating PCB",
	"of view.with PCB layout",
	"placement and track routing,",
	"can often be the most time",
	"And if you use circuit simulation",
	"you are going to spend even more"
};
uchar Disp_Buffer[32];
void Delayxms(uint ms)
{
 	uchar i;
	while(ms--)
	{
	 	for(i=0;i<120;i++);
	}
}

void H_Scroll_Display()
{
	uchar m,n,t = 0,L=0;
	uchar *p = Msg[0];
	uchar *q = Msg[Line_Count] + strlen(Msg[Line_Count]);
	for(m=0;m<16;m++)
			Disp_Buffer[m]=' ';	
	while(p<q)
	{
		for(m=16;m<32&&p<q;m++)
		{
		 	if(*p != '\0')
			{
				Disp_Buffer[m] = *p++; 	
			}
			else
			{
			 	if(++t>Line_Count)
					break;
				p = Msg[t];
				Disp_Buffer[m] = *p++;
			}
		}
		for(n=m;n<32;n++)
			Disp_Buffer[n]=' ';
		for(m=0;m<=16;m++)
		{
		 	while(F0)
		 		Delayxms(5);
		   	while(F0)
		 		Delayxms(5);
			Delayxms(20);
		}
		L = (L==0)? 1:0;
		Delayxms(200);
	}
	if(L==1)
}

void EX_INT0() interrupt 0
{
 	F0 = !F0;
}

void main()
{
 	uint Count = 0;
	IE = 0x81;
	IT0 = 1;
	F0  = 0;
	Initialize_LCD();
	ShowString(0,0,Prompt);
	ShowString(0,1,Prompt+16);
	while(1)
	{
	 	if(K1 == 0)
		{
		 	V_Scroll_Display();
			Delayxms(200);
		}
		else if(K2 == 0)
		{
		 	H_Scroll_Display();
			Delayxms(200);	
		}
	}
}

项目获取:

https://gitee.com/feifei1122/simulation-project

  • 6
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值