标题: 各位大神有没有关于液晶动态显示数字的相关程序 求分享 [打印本页]

作者: 月落霓虹    时间: 2018-4-4 08:40
标题: 各位大神有没有关于液晶动态显示数字的相关程序 求分享
各位大神有没有关于液晶动态显示数字的相关程序,给小弟参考一下呀!
作者: qq347336987    时间: 2018-4-4 11:32
1602的要吗
作者: qq347336987    时间: 2018-4-4 11:32
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit lcden=P3^4;
sbit rs=P3^5;
sbit rw=P3^6;       
sbit dula=P2^6;
sbit wela=P2^7;
uchar table1[]="xingming:xxxxxxxxxxxx";
uchar table2[]="xuehao:11111111111  ";
void delay(uint x)
{
        uint a,b;
        for(a=x;a>0;a--)
                for(b=10;b>0;b--);
}

void delay1(uint x)
{
        uint a,b;
        for(a=x;a>0;a--)
                for(b=100;b>0;b--);
}

void write_com(uchar com)   
{
        P0=com;
        rs=0;
        lcden=0;
       
        lcden=1;
       
        lcden=0;
       
}

void write_date(uchar date)
{
        P0=date;
        rs=1;
        lcden=0;
        delay(10);
        lcden=1;
        delay(10);
        lcden=0;
       
}

void init()
{
   rw=0;
        dula=0;
        wela=0;
        write_com(0x38);   //显示模式设置:16×2显示,5×7点阵,8位数据接口
        delay(20);
        write_com(0x0c);   //显示模式设置
        delay(20);
        write_com(0x07);   //显示模式设置:光标右移,字符不移
        delay(20);
        write_com(0x01);   //清屏幕指令,将以前的显示内容清除
        delay(20);       
}

void main()
{
        uchar a;
        init();

        write_com(0x80);         
        delay(50);
        for(a=0;a<18;a++)
        {
        write_date(table1[a]);
        delay(40);               
        }

        write_com(0x80+0x40);
        delay(50);
        for(a=0;a<18;a++)
        {
        write_date(table2[a]);
        delay(40);               
        }

        for(a=0;a<16;a++)
        {
                write_com(0x18); //左移
                delay1(1000);
        }
        while(1);
}
作者: qq347336987    时间: 2018-4-4 11:34
1602


#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit lcden=P3^4;
sbit rs=P3^5;
sbit rw=P3^6;       
sbit dula=P2^6;
sbit wela=P2^7;
uchar table1[]="xingming:xxxxxxxxxxxx";
uchar table2[]="xuehao:11111111111  ";
void delay(uint x)
{
        uint a,b;
        for(a=x;a>0;a--)
                for(b=10;b>0;b--);
}

void delay1(uint x)
{
        uint a,b;
        for(a=x;a>0;a--)
                for(b=100;b>0;b--);
}

void write_com(uchar com)   
{
        P0=com;
        rs=0;
        lcden=0;
       
        lcden=1;
       
        lcden=0;
       
}

void write_date(uchar date)
{
        P0=date;
        rs=1;
        lcden=0;
        delay(10);
        lcden=1;
        delay(10);
        lcden=0;
       
}

void init()
{
   rw=0;
        dula=0;
        wela=0;
        write_com(0x38);   //显示模式设置:16×2显示,5×7点阵,8位数据接口
        delay(20);
        write_com(0x0c);   //显示模式设置
        delay(20);
        write_com(0x07);   //显示模式设置:光标右移,字符不移
        delay(20);
        write_com(0x01);   //清屏幕指令,将以前的显示内容清除
        delay(20);       
}

void main()
{
        uchar a;
        init();

        write_com(0x80);         
        delay(50);
        for(a=0;a<18;a++)
        {
        write_date(table1[a]);
        delay(40);               
        }

        write_com(0x80+0x40);
        delay(50);
        for(a=0;a<18;a++)
        {
        write_date(table2[a]);
        delay(40);               
        }

        for(a=0;a<16;a++)
        {
                write_com(0x18); //左移
                delay1(1000);
        }
        while(1);
}
作者: 月落霓虹    时间: 2018-4-5 10:56
qq347336987 发表于 2018-4-4 11:32
#include
#define uchar unsigned char
#define uint unsigned int

谢谢




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1