最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

利用單片機(jī)實(shí)現(xiàn)的電磁密碼鎖

2023-05-20 12:50 作者:飛行器發(fā)明  | 我要投稿

C代碼如下:

#include"reg52.h"

#include"intrins.h"

#include"stdlib.h"

#include"string.h"

#define uchar unsigned char

#define uint unsigned int

//define port

sbit suo=P2^0;

sbit lcd_e=P2^5;

sbit lcd_wr=P2^6;

sbit lcd_rs=P2^7;

uchar key,i=0;

uchar? putmima[5];

uchar code mima[]={"11111"};

uchar code dis2[]={"please input passwd"};

void delayxms(uint xms)

{

uint i,j;

for(i=xms;i>0;i--)

for(j=114;j>0;j--);

}

//write instructions to LCD

//rs=l,rw=l,e=1,d0-d7=data


void write_com(uchar com)

{

_nop_();

lcd_rs=0;

lcd_wr=0;

lcd_e=1;

P0=com;

lcd_e=0;

delayxms(5);

}

void write_data(uchar data0)

{

_nop_();

lcd_e=1;

_nop_();

lcd_rs=1;

lcd_wr=0;

P0=data0;

lcd_e=0;

delayxms(100);

}

void init()

{

lcd_e=1;

write_com(0x38);

write_com(0x0c);

write_com(0x06);

write_com(0x01);

}

void matrixkeyscan()

{

P3=0xfe;//first? line 11111110=P3

if(P3==0Xee)

{

delayxms(10);

if(P3==0Xee)

{

key='c';

while(!P3==0Xee);

putmima[i]=key;

i++;

write_data('*');

}

}

if(P3==0Xde)

{

delayxms(10);

if(P3==0Xde)

{

key='d';

while(!P3==0Xde);

putmima[i]=key;

i++;

write_data('*');

}

}

if(P3==0Xbe)

{ delayxms(10);

if(P3==0Xbe)

{

key='e';

while(!P3==0Xbe);

putmima[i]=key;

i++;

write_data('*');

}

}

if(P3==0X7e)

{

delayxms(10);

if(P3==0X7e)

{

key='f';

while(!P3==0X7e);

putmima[i]=key;

i++;

write_data('*');

}

}

P3=0xfd;// second line.

if(P3==0Xed)

{

delayxms(10);

if(P3==0Xed)

{

key='8';

while(!P3==0Xed);

putmima[i]=key;

i++;

write_data('*');

}

}

if(P3==0Xdd)

{

delayxms(10);

if(P3==0Xdd)

{

key='9';

while(!P3==0Xdd);

putmima[i]=key;

i++;

write_data('*');

}

}

if(P3==0Xbd)

{

delayxms(10);

if(P3==0Xbd)

{

key='a';

while(!P3==0Xbd);

putmima[i]=key;

i++;

write_data('*');

}

}

if(P3==0X7d)

{

delayxms(10);

if(P3==0X7d)

{

key='b';

while(!P3==0X7d);

putmima[i]=key;

i++;

write_data('*');

}

}

P3=0xfb;// third line.

if(P3==0Xeb)

{

delayxms(10);

if(P3==0Xeb)

{

key='4';

while(!P3==0Xed);

putmima[i]=key;

i++;

write_data('*');

}

}

if(P3==0Xdb)

{

delayxms(10);

if(P3==0Xdb)

{

key='5';

while(!P3==0Xdb);

putmima[i]=key;

i++;

write_data('*');

}

}

if(P3==0Xbb)

{

delayxms(10);

if(P3==0Xbb)

{

key='6';

while(!P3==0Xbb);

putmima[i]=key;

i++;

write_data('*');

}

}

if(P3==0X7b)

{

delayxms(10);

if(P3==0X7b)

{

key='7';

while(!P3==0X7b);

putmima[i]=key;

i++;

write_data('*');

}

}

? P3=0xf7;// fourth line.

if(P3==0Xe7)

{

delayxms(10);

if(P3==0Xe7)

{

key='0';

while(!P3==0Xe7);

putmima[i]=key;

i++;

write_data('*');

}

}

if(P3==0Xd7)

{

delayxms(10);

if(P3==0Xd7)

{

key='1';

while(!P3==0Xd7);

putmima[i]=key;

i++;

write_data('*');

}

}

if(P3==0Xb7)

{ delayxms(10);

if(P3==0Xb7)

{

key='2';

while(!P3==0Xb7);

putmima[i]=key;

i++;

write_data('*');

}

}

if(P3==0X77)

{

delayxms(10);

if(P3==0X77)

{

key='3';

while(!P3==0X77);

putmima[i]=key;

i++;

write_data('*');

}

}?

}


void main()

{ uchar num;

init();

write_com(0x80);

for(num=0;num<30;num++)

{

write_data(dis2[num]);

delayxms(1);

}

write_com(0x80+0x44);

while(i<5)

{

matrixkeyscan();

}

if(putmima[0]==mima[0])

{

if(putmima[1]==mima[1])

{

if(putmima[2]==mima[2])

{

if(putmima[3]==mima[3])

{

if(putmima[4]==mima[4])

{

suo=0;

}

}

}

}

}

while(1);

}


利用單片機(jī)實(shí)現(xiàn)的電磁密碼鎖的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
彰武县| 抚顺县| 池州市| 灌南县| 漳浦县| 泸定县| 桑日县| 长武县| 吕梁市| 普陀区| 许昌县| 庆元县| 陕西省| 伊春市| 寿光市| 浦县| 青神县| 郸城县| 屏山县| 南木林县| 彭州市| 高陵县| 自贡市| 博湖县| 嘉义市| 裕民县| 平罗县| 贡山| 达尔| 黑龙江省| 泗洪县| 石楼县| 南阳市| 常熟市| 岳普湖县| 汶上县| 扶余县| 平乐县| 金阳县| 花莲县| 武隆县|