77范文网 - 专业文章范例文档资料分享平台

电子密码锁程序

来源:网络收集 时间:2018-12-04 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

******************************************************** *文件名:Password_clock

*功能:利用AT24c02,输入密码播放一段音乐,同时可以修改密码 *创建人:计算机科学与信息工程学院 米中勤 2011-9-5

*********************************************************/ #include #include #include

#define uint unsigned int #define uchar unsigned char

sbit lcd_rs=P2^5;//1602lcd数据/命令选择引脚 sbit lcd_rw=P2^6;//1602lcd读写引脚 sbit lcd_en=P2^7;//1602lcd使能端 sbit scl=P1^5; //24c08 SCL sbit sda=P3^6; //24c08 SDA sbit Int0=P3^2; //外部中断0 sbit In=P3^3;//输入密码键 sbit Ch=P3^4;//修改密码键 sbit d=P1^2;//蜂鸣器驱动引脚 uchar Count;

uchar m,tmp,lock_flag; static uint kai=0;

uchar code Seg_table[]=%uchar Enter[14]=%uchar init_password[6]=%uchar a[5]=\

uchar b[16]=\/*以下数组是音符编码*/

unsigned char code pu[282]={ 0x03,0xfb,0x05,0x00,0x00,0x04, 0x03,0xfb,0x02,0x03,0xfb,0x02, 0x43,0xfc,0x02,0x0b,0xfc,0x02, 0x8f,0xfb,0x02,0x8f,0xfb,0x02, 0x8f,0xfb,0x02,0x03,0xfb,0x02, 0x8f,0xfb,0x05,0x00,0x00,0x03, 0x43,0xfc,0x02,0x8f,0xfb,0x02, 0x43,0xfc,0x02,0x8f,0xfb,0x02, 0x43,0xfc,0x04,0x8f,0xfb,0x02, 0x03,0xfb,0x02,0x8f,0xfb,0x02, 0x03,0xfb,0x02,0x14,0xfa,0x02, 0x8f,0xfb,0x02,0x03,0xfb,0x05, 0x00,0x00,0x03,0x03,0xfb,0x05, 0x00,0x00,0x04,0x03,0xfb,0x02, 0x03,0xfb,0x02,0x43,0xfc,0x02,

0x0b,0xfc,0x02,0x8f,0xfb,0x02, 0x8f,0xfb,0x02,0x8f,0xfb,0x02, 0x03,0xfb,0x02,0x8f,0xfb,0x02, 0x00,0x00,0x03,0x43,0xfc,0x02, 0x8f,0xfb,0x02,0x43,0xfc,0x02, 0x8f,0xfb,0x02,0x43,0xfc,0x04, 0x8f,0xfb,0x02,0x03,0xfb,0x02, 0x8f,0xfb,0x02,0x03,0xfb,0x02, 0x8f,0xfb,0x02,0x08,0xfd,0x02, 0xab,0xfc,0x02,0x00,0x00,0x03, 0x08,0xfd,0x02,0xab,0xfc,0x02, 0x08,0xfd,0x02,0xab,0xfc,0x02, 0x08,0xfd,0x04,0xab,0xfc,0x02, 0x43,0xfc,0x02,0xab,0xfc,0x02, 0x43,0xfc,0x02,0x43,0xfc,0x04, 0x08,0xfd,0x04,0x03,0xfb,0x02, 0x8f,0xfb,0x02,0x08,0xfd,0x04, 0xab,0xfc,0x04,0xab,0xfc,0x02, 0x43,0xfc,0x02,0x43,0xfc,0x04, 0x43,0xfc,0x04,0x8f,0xfb,0x04, 0xab,0xfc,0x04,0x00,0x00,0x04, 0x08,0xfd,0x02,0xab,0xfc,0x02, 0x08,0xfd,0x02,0xab,0xfc,0x02, 0x08,0xfd,0x04,0xab,0xfc,0x02, 0x43,0xfc,0x02,0xab,0xfc,0x02, 0x43,0xfc,0x02,0x43,0xfc,0x02, 0x08,0xfd,0x04,0x03,0xfb,0x02, 0x8f,0xfb,0x02,0x08,0xfd,0x02, 0xab,0xfc,0x02,0xab,0xfc,0x05, 0x00,0x00,0x02,0x03,0xfb,0x02, 0x8f,0xfb,0x02,0xab,0xfc,0x04, 0x43,0xfc,0x02,0x43,0xfc,0x05 };

/******************************************************************* *名称:delay_music() *功能:音乐节拍延时

*输入:a a=1,1/16/拍,a=2,1/8拍,a=4,1/4拍 *输出:无

********************************************************************/ void delay_music(unsigned char a) {

unsigned int b; while(a--)

{

for(b=10300;b>=1;b--); } }

/******************************************************************** * 名称 : delay1() * 功能 : 短暂延时 * 输入 : x * 输出 : 无

***********************************************************************/ void delay1(uchar x) { uint i;

for(i=0; i

/******************************************************************** * 名称 : Delay_1ms()

* 功能 : 延时,延时时间为 1ms * i * 输入 : i(延时1ms的个数) * 输出 : 无

***********************************************************************/ void Delay_1ms(uint i) {

uchar x, j;

for(j=0; j

for(x=0; x<=148; x++); }

/******************************************************************** * 名称 : Delay_xMs()

* 功能 : 延时子程序,经过软件调试,测得延时程序大概为55us. * 输入 : x * 输出 : 无

***********************************************************************/ void Delay_xMs(uint x) {

uint i,j;

for(i=0; i

for(j=0; j<3; j++); } }

/******************************************************************** * 名称 : flash()

* 功能 : 延时,时间为2个NOP,大概为2US

* 输入 : 无 * 输出 : 无

***********************************************************************/ void flash(void) {

_nop_(); _nop_(); }

/******************************************** *名称:delay()

*功能:延时大概140us *输入:无 *输出:无

*********************************************/ void delay() { int i,j;

for(i=0; i<=10; i++) for(j=0; j<=2; j++); }

/********************************************* *名称:lcd_writecom(uchar com) *功能:向1602写入命令 *输入:命令 *输出:无

**********************************************/ void lcd_writecom(uchar com) {

lcd_rs=0; lcd_rw=0; lcd_en=0; P0=com; delay(); lcd_en=1; delay(); lcd_en=0; }

/********************************************** *名称:lcd_readdata(uchar dat) *功能:向1602lcd写入数据 *输入:dat *输出:无

***********************************************/

void lcd_writedata(uchar dat) {

lcd_rs=1; lcd_rw=0; lcd_en=0; P0=dat; delay(); lcd_en=1; delay(); lcd_en=0; }

/***************************************** *名称:lcd_init()

*功能:1602lcd初始化 *输入:无 *输出:无

******************************************/ void lcd_init() {

lcd_writecom(0x38); lcd_writecom(0x0c); lcd_writecom(0x06); lcd_writecom(0x01); lcd_writecom(0x80); }

/************************************************ *名称:lcd_char(uchar row ,uchar cloum,uchar dat)

*功能:在lcd的第row行,第cloum列,写入数据dat *输入:row cloum dat

*************************************************/ void lcd_char(uchar row ,uchar cloum,uchar dat) {

if(row==1) {

lcd_writecom(0x80+cloum); lcd_writedata(dat); } else {

lcd_writecom(0x80+0x40+cloum); lcd_writedata(dat); } }

/*********************************************

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库电子密码锁程序在线全文阅读。

电子密码锁程序.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/340736.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: