毕业设计基于51单片机的密码锁设计程序
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
uchar read_ds1302_data(uchar addr);
void set_real_time(uchar *pclock);
void get_real_time(uchar Curtime[]);
#endif
#include "delay.h"
#include "1602.h"
void lcd_busy_wait() /*LCD1602忙等待*/
pclock++;
addr+=2;
}
//write_ds1302_dat(0x8e,0x80);
EA=1;
}
void get_real_time(uchar Curtime[])
{
uchar j;
uchar address=0x81;
EA=0;
for(j=0;j<7;j++)
{
Curtime[j]=read_ds1302_data(address);
lcd_delay(10);
write_com(0x08);
write_com(0x01);
write_com(0x06);
write_com(0x0c);
lcd_data_port = 0xff; /*释放数据端口*/
}
#ifndef __1602_H__
#define __1602_H__
#include <reg52.h>
lcd_rs_port=1;
lcd_rw_port =0;
lcd_en_port=0;
P0=dat;
lcd_en_port=1;
lcd_en_port=0;
}
void wtite_lcd_1602_dat(uchar x_pos,uchar y_pos,uchar dat)
{
x_pos&=0x0f;
sbit T_CLK=P2^4;
sbit T_EN=P1^0;
sbit ACC0=ACC^0;
sbit ACC7=ACC^7;
void write_ds1302_byte(uchar dat);
uchar read_ds1302_byte();
void write_ds1302_dat(uchar addr,uchar dat);
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit lcd_rs_port=P3^5;
sbit lcd_rw_port=P3^6;
sbit lcd_en_port=P3^4;
#define lcd_data_port P0
y_pos&=0x01;
if(y_pos==0)
{
x_pos=x_pos+0x80;
}
else
{
x_pos=x_pos+0x80+0x40;
}
write_com(x_pos);
lcd_busy_wait();
lcd_rs_port=1;
lcd_rw_port=0;
lcd_en_port=0;
P0=dat;
void lcd_busy_wait();
void write_com(uchar command);
void write_data(uchar dat);
void wtite_lcd_1602_dat(uchar x_pos,uchar y_pos,uchar dat);
T_EN=0;
T_CLK=0;
return (date);
}
void set_real_time(uchar *pclock)
{
uchar i,addr=0x80;
EA=0;
write_ds1302_dat(0x8e,0x00);
for(i=0;i<7;i++)
{
write_ds1302_dat(addr,*pclock);
write_ds1302_byte(dat);
T_CLK=1;
T_EN=0;
}
uchar read_ds1302_data(uchar addr)
{
uchar date;
T_EN=0;
T_CLK=0;
T_EN=1;
write_ds1302_byte(addr);
date=read_ds1302_byte();
for(i=0;i<8;i++)
{
ACC=ACC>>1;
ACC7=T_IO;
T_CLK=1;
T_CLK=0;
}
return (ACC);
}
void write_ds1302_dat(uchar addr,uchar dat)
{
T_EN=0;
T_CLK=0;
百度文库T_EN=1;
write_ds1302_byte(addr);
{
lcd_rs_port = 0;
lcd_rw_port = 1;
lcd_en_port = 1;
lcd_data_port = 0xff;
while (lcd_data_port&0x80);
lcd_en_port = 0;
}
void write_com(uchar command) /*LCD1602命令字写入*/
{
lcd_busy_wait();
lcd_rs_port = 0;
lcd_rw_port = 0;
lcd_en_port = 0;
lcd_data_port = command;
lcd_en_port = 1;
lcd_en_port = 0;
}
void write_data(uchar dat)
{
lcd_busy_wait();
lcd_en_port=1;
lcd_en_port=0;
}
void lcd_init() /*LCD1602初始化*/
{
lcd_delay(20);
write_com(0x38);
lcd_delay(100);
write_com(0x38);
lcd_delay(50);
write_com(0x38);
#include "1302.h"
void write_ds1302_byte(uchar dat)
{
uchar i;
for(i=0;i<8;i++)
{
T_IO=dat&0x01;
T_CLK=1;
T_CLK=0;
dat=dat>>1;
}
}
uchar read_ds1302_byte()
{
uchar i;
address+=2;
}
EA=1;
}
#ifndef __1302_H__
#define __1302_H__
#include <reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit T_IO=P2^5;
void set_real_time(uchar *pclock);
void get_real_time(uchar Curtime[]);
#endif
#include "delay.h"
#include "1602.h"
void lcd_busy_wait() /*LCD1602忙等待*/
pclock++;
addr+=2;
}
//write_ds1302_dat(0x8e,0x80);
EA=1;
}
void get_real_time(uchar Curtime[])
{
uchar j;
uchar address=0x81;
EA=0;
for(j=0;j<7;j++)
{
Curtime[j]=read_ds1302_data(address);
lcd_delay(10);
write_com(0x08);
write_com(0x01);
write_com(0x06);
write_com(0x0c);
lcd_data_port = 0xff; /*释放数据端口*/
}
#ifndef __1602_H__
#define __1602_H__
#include <reg52.h>
lcd_rs_port=1;
lcd_rw_port =0;
lcd_en_port=0;
P0=dat;
lcd_en_port=1;
lcd_en_port=0;
}
void wtite_lcd_1602_dat(uchar x_pos,uchar y_pos,uchar dat)
{
x_pos&=0x0f;
sbit T_CLK=P2^4;
sbit T_EN=P1^0;
sbit ACC0=ACC^0;
sbit ACC7=ACC^7;
void write_ds1302_byte(uchar dat);
uchar read_ds1302_byte();
void write_ds1302_dat(uchar addr,uchar dat);
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit lcd_rs_port=P3^5;
sbit lcd_rw_port=P3^6;
sbit lcd_en_port=P3^4;
#define lcd_data_port P0
y_pos&=0x01;
if(y_pos==0)
{
x_pos=x_pos+0x80;
}
else
{
x_pos=x_pos+0x80+0x40;
}
write_com(x_pos);
lcd_busy_wait();
lcd_rs_port=1;
lcd_rw_port=0;
lcd_en_port=0;
P0=dat;
void lcd_busy_wait();
void write_com(uchar command);
void write_data(uchar dat);
void wtite_lcd_1602_dat(uchar x_pos,uchar y_pos,uchar dat);
T_EN=0;
T_CLK=0;
return (date);
}
void set_real_time(uchar *pclock)
{
uchar i,addr=0x80;
EA=0;
write_ds1302_dat(0x8e,0x00);
for(i=0;i<7;i++)
{
write_ds1302_dat(addr,*pclock);
write_ds1302_byte(dat);
T_CLK=1;
T_EN=0;
}
uchar read_ds1302_data(uchar addr)
{
uchar date;
T_EN=0;
T_CLK=0;
T_EN=1;
write_ds1302_byte(addr);
date=read_ds1302_byte();
for(i=0;i<8;i++)
{
ACC=ACC>>1;
ACC7=T_IO;
T_CLK=1;
T_CLK=0;
}
return (ACC);
}
void write_ds1302_dat(uchar addr,uchar dat)
{
T_EN=0;
T_CLK=0;
百度文库T_EN=1;
write_ds1302_byte(addr);
{
lcd_rs_port = 0;
lcd_rw_port = 1;
lcd_en_port = 1;
lcd_data_port = 0xff;
while (lcd_data_port&0x80);
lcd_en_port = 0;
}
void write_com(uchar command) /*LCD1602命令字写入*/
{
lcd_busy_wait();
lcd_rs_port = 0;
lcd_rw_port = 0;
lcd_en_port = 0;
lcd_data_port = command;
lcd_en_port = 1;
lcd_en_port = 0;
}
void write_data(uchar dat)
{
lcd_busy_wait();
lcd_en_port=1;
lcd_en_port=0;
}
void lcd_init() /*LCD1602初始化*/
{
lcd_delay(20);
write_com(0x38);
lcd_delay(100);
write_com(0x38);
lcd_delay(50);
write_com(0x38);
#include "1302.h"
void write_ds1302_byte(uchar dat)
{
uchar i;
for(i=0;i<8;i++)
{
T_IO=dat&0x01;
T_CLK=1;
T_CLK=0;
dat=dat>>1;
}
}
uchar read_ds1302_byte()
{
uchar i;
address+=2;
}
EA=1;
}
#ifndef __1302_H__
#define __1302_H__
#include <reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit T_IO=P2^5;