1. 基于单片机的人脸识别门禁
单片机的人脸识别方式利用的就是NFC功能键。
打开设备的NFC功能,然后选择扫描卡片。
添加门禁卡的扫码就可以。
2. 51单片机独立按键控制门禁密码
#include "reg51.h"
#include "display_7seg_4.h"
sbit KEY1 = P1^0;
sbit KEY2 = P1^1;
sbit KEY3 = P1^2;
sbit KEY4 = P1^3;
sbit KEY5 = P3^0;
sbit KEY6 = P3^1;
sbit KEY7 = P3^2;
sbit KEY8 = P3^3;
sbit KEY9 = P3^4;
sbit KEY0 = P3^5;
sbit KEYE = P3^6;
sbit LED = P1^5;
unsigned int count=0;
void main(void)
{
unsigned char keyvalue;
unsigned char i=0;
unsigned char dis[4]={10,10,10,10};
unsigned int password;
LED = 0;
while(1)
{
keyvalue = 20;
if(KEY1 == 0)
{
while(!KEY1);
keyvalue = 1;
}
if(KEY2 == 0)
{
while(!KEY2);
keyvalue = 2;
}
if(KEY3 == 0)
{
while(!KEY3);
keyvalue = 3;
}
if(KEY4 == 0)
{
while(!KEY4);
keyvalue = 4;
}
if(KEY5 == 0)
{
while(!KEY5);
keyvalue = 5;
}
if(KEY6 == 0)
{
while(!KEY6);
keyvalue = 6;
}
if(KEY7 == 0)
{
while(!KEY7);
keyvalue = 7;
}
if(KEY8 == 0)
{
while(!KEY8);
keyvalue = 8;
}
if(KEY9 == 0)
{
while(!KEY9);
keyvalue = 9;
}
if(KEY0 == 0)
{
while(!KEY0);
keyvalue = 0;
}
if(KEYE == 0)
{
while(!KEYE);
keyvalue = 10;
}
if(keyvalue != 20)
{
if(keyvalue == 10)
{
i=0;
password = dis[0]*1000+dis[1]*100+dis[2]*10+dis[3];
if(password == 1234)
{
LED = 1;
}
else
{
LED = 0;
}
dis[0] = 10;
dis[1] = 10;
dis[2] = 10;
dis[3] = 10;
}
else
{
dis[i] = keyvalue;
i++;
}
}
display_seg(dis);
}
}