标题:
基于51单片机的学号+名字 proteus仿真及程序
[打印本页]
作者:
Dencince
时间:
2018-11-27 17:00
标题:
基于51单片机的学号+名字 proteus仿真及程序
基于AT89C51单片机,使用LM016L显示屏
通过KEIL编写输入学号+拼音姓名,输出HEX文件到
#include<reg52.h>
int init(); //声明初始化函数
int write_com(unsigned char);//声明写命令函数
int write_date(unsigned char);//声明写数据函数
int delay(unsigned char);//声明延迟函数
unsigned char x;
sbit RS = P1^0;
sbit RW = P1^1;
sbit EN = P1^2;
unsigned char code table[]="15829806!";
unsigned char code table1[]="UANG DREG XEQNG";
int main(void)//主函数
{
init();
write_com(0x80);
for(x=0;x<8;x++)
{
write_date(table[x]);
delay(150);
}
write_com(0x80+0x40);
for(x=0;x<17;x++)
{
write_date(table1[x]);
delay(150);
}
while(1);
return 0;
}
int init()//初始化函数体
{
EN = 0;
write_com(0X38);//设置16*2显示,5*7点阵,8位数据接口
write_com(0X0C);//设置开显示,不显示光标
write_com(0X06);//写一个字符时,整屏右移
write_com(0X01);//显示清零
return 0;
}
int write_com(unsigned char com)//写命令的函数体
{
RS = 0;
RW = 0;
P0 = com;
delay(5);
EN = 1;
delay(5);
EN = 0;
return 0;
}
int write_date(unsigned char date)//写数据的函数体
{
RS = 1;
RW = 0;
P0 = date;
delay(5);
EN = 1;
delay(5);
EN = 0;
return 0;
}
int delay(unsigned char xms)
{
unsigned char x,y;
for(x=xms;x>0;x--)
for(y=110;y>0;y--);
return 0;
}
复制代码
单片机中运行即可
学号.png
(68.84 KB, 下载次数: 28)
下载附件
2018-11-27 17:00 上传
工程图
作者:
Dencince
时间:
2018-11-27 17:01
送给有需要的同学,.c文件用记事本打开也可以
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1