您好,欢迎来到搜客无忧!

程控密码锁课程设计_密码锁控制课程设计

  作者:正苗启德发表时间:2023-07-09点击量:82

电子密码锁课程设计

这程序是单片机STC 89c52单片机控制

已经调过的

希望给你可行

include

include

define uchar unsigned char

define uint unsigned int

uchar b10={

0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,

0x80,0x90},

a8={0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88};

uchar k8,s8,b18;

uchar i,g,p=0,g1;

sbit SDA = P2^7;

sbit SCL = P2^6;

sbit P36= P3^6;

void delayms(uint ms)

{

uchar k;

while(ms--)

{

for(k =0; k <120; k++);

}

}

void display1()

{ uchar y;

y=P20XF8;

P2=y+0;

P0=0x91;

}

void display2()

{ uchar y ;

y=P20XF8;

P2=y+0;

P0=0xc1;

}

void display()

{ uchar x,m;

for(i =0;i

{

m=b1i;

P0=bm;

x=P20XF8;

P2=x+i;

delayms(3);

}

}

void delayNOP()

{

_nop_();_nop_();_nop_();_nop_();

}

void start()

{

SDA =1;

SCL =1;

delayNOP();

SDA =0;

delayNOP();

SCL =0;

}

void stop()

{

SDA =0;

delayNOP();

SCL =1;

delayNOP();

SDA =1;

}

uchar shin()

{

uchar i,read_data;

for(i =0; i <8; i++)

{

SCL =1;

read_data <<=1;

read_data |= SDA;

SCL =0;

}

return(read_data);

}

bit shout(uchar write_data)

{

uchar i;

bit ack_bit;

{

SDA =(bit)(write_data 0x80);

_nop_();

SCL =1;

delayNOP();

SCL =0;

write_data <<=1;

}

delayNOP();

SCL =1;

delayNOP();

ack_bit = SDA;

SCL =0;

}

void write_byte(uchar addr, uchar write_data)

{

start();

shout(OP_WRITE);

shout(addr);

shout(write_data);

stop();

}

void fill_byte(uchar fill_size,uchar fill_data)

{

uchar i;

for(i =0; i < fill_size; i++)

{

write_byte(i, fill_data);

}

}

uchar read_current()

{

uchar read_data;

start();

shout(OP_READ);

read_data = shin();

stop();

return read_data;

}

uchar read_random(uchar random_addr)

{

start();

shout(OP_WRITE);

shout(random_addr);

return(read_current());

}

uchar Keycan(void)

{

uchar a, b;

{

if((P10xF0)!=0xF0)

while((a0x10)!=0)

{

{

b =(P10xF0)|0x0F;

while((P10xF0)!=0xF0)

{

}

}

else

}

}

}

}

void KeyDispaly(uchar key)

{ if(key!=0)

{

switch(key)

{

case 0x11: g=0; break;

case 0x21: g=1; break;

case 0x41: g=2; break;

case 0x81: g=3; break;

case 0x12: g=4; break;

case 0x22: g=5; break;

case 0x42: g=6; break;

case 0x82: g=7; break;

case 0x14: g=8; break;

case 0x24: g=9; break;

case 0x44: g1=10;break;

default: break;

}

if(g1!=10)

{

b17=b16;

b16=b15;

b15=b14;

b14=b13;

b13=b12;

b12=b11;

b11=b10;

b10=g;

p++;

if(p>8) p=8;

}

else if(g110)

{

if((k0b10)(k1b11)(k2b12)(k6b16)

(k3b13)(k4b14)(k5b15)(k7b17))

{P36=0;g1=0;

display1();

delayms(2000);

P36=1;}

else

{ g1=0;

display2();

delayms(2000);

}

b10=0;b11=0;b12=0;b13=0;

b14=0;b15=0;b16=0;b17=0;

}

}

}

void main(void)

{

uchar j=0,b=200;

uchar Key;

SDA =1;

SCL =1;

{

write_byte(i,ai);

}

{

si=read_random(i);

}

for(i =0;i <4; i++)

{

kj=(si0xf0)>>4;

j++;

kj=si0x0f;

j++;

}

while(1)

{

Key = Keycan();

KeyDispaly(Key);

display();

}

}

申请试听课程

提交后,免费为您匹配专业课程

机构入驻 | 帮选课 | 公司介绍 | 联系我们 | 网站地图

版权所有:(c)2024 武汉涵宝信息科技有限公司 All Rights Reserved 备案号:鄂ICP备2022007586号-13 技术支持:搜客无忧