Small project: anti-theft system design of single chip microcomputer + human body infrared induction (simulation + source code + PCB file)

Design description
1. According to the system function requirements and considering the cost performance of the product, the overall scheme of the system is designed, including the system selection, the function of the selected chip, the reasonable design of the chip peripheral circuit, etc.
2. Research and implementation of system hardware anti-jamming technology and software anti-jamming technology.
3. Co-simulation and debugging of system hardware and software.

This design is designed for ordinary household anti-theft. Compared with similar function systems, it has the following innovations:
(1) High portability. This design considers the characteristics of modern homes and refers to most of the stolen situations, suitable for any family use.
(2) Low cost. This design uses a single-chip microcomputer as a control chip, less peripheral circuits are required, and all sub-circuits can be purchased from the market, and the manufacturing cost is low.
(3) The function expandability is good. The design can be slightly modified to add functions such as checking fire or gas leakage, and has great development prospects.
(4) High security. This design takes into account its security and uses a fully enclosed installation so that thieves cannot destroy their equipment and have good security.

The circuit diagram of the anti-theft system based on the 51 single-chip microcomputer and the infrared sensor module of the human body is as follows:
Insert picture description here
physical map The
Insert picture description here
Insert picture description here
Insert picture description here
anti-theft system simulation schematic diagram is as follows (proteus simulation engineering file)
Insert picture description here
Insert picture description here
Insert picture description here
The anti-theft system circuit schematic diagram and PCB diagram drawn by Altium Designer are as follows:
Insert picture description hereSingle-chip program draft code show as below:

#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit huang = P2 ^ 0; // Yellow light
sbit lv = P2 ^ 2; // Green light
sbit hong = P2 ^ 4; // Red light

sbit hongwai = P1 ^ 0; // Pyroelectric
sbit butter = P2 ^ 6; // Buzzer low level turns on the buzzer

sbit baojing = P1 ^ 1 // direct alarm button;
sbit bufang = P1 ^ 7; // arming button
sbit quxiao = P3 ^ 4; // cancel button
uchar tt = 0; // timer variable
uchar num = 0; / / Timed timing variable
uchar flag = 0; // flag bit
void timer1init (void) // Timer 1, 16-bit mode 2
{EA = 0;
TMOD = 0x11; // Set timer 0 to work mode 1
TH0 = (65536-10000) / 256;
TL0 = (65536-10000)% 256;
ET0 = 1; // Start timer 0 interrupt
TR0 = 1; // Start timer 0
tt = 0; //
EA = 0; / / Off total interrupt
}
void delay (uint z) // Delay function
{
uint x, y;
for (x = z; x> 0; x–)
for (y = 110; y> 0; y–);
}
void main () // Main function
{
huang = 0; // Initial yellow light is on
lv = 0; // Initial green light is on
hong = 0; // Initial red light is on
timer1init (); // Initialization timer
while (1)
{

        if(!baojing)//如果直接报警键被按下
                            {
                                    delay(5);//延时消抖
                                    if(!baojing)//判断报警键是不是被按下
                                    { 
                                      hong=1;//红灯亮
                                      lv=0;        //绿灯灭
                                      flag=7;//标志位等于7
                                      butter=0;//蜂鸣器响
                                      EA=0;//关中断
                                    }
                                    while(!baojing);//判断按键是不是弹开
                                    delay(5);//如果弹开延时消抖
                                    while(!baojing);//弹开后跳出程序
                            }            
         if((!bufang)&&(flag<4))//在初始状态和按下取消键后可以进去这个函数
                            {
                                    delay(5);//延时消抖
                                    if(!bufang)//如果布防被按下
                                    { 
                                       EA=1;   //开定时器
                                       flag=2;//另=2
                                    }
                                    while(!bufang);//布防键是不是弹开
                                    delay(5);//延时
                                    while(!bufang);//布防键弹开
                            }
                    if(!quxiao)//如果取消键按下
                            {
                                    delay(5);//延时消抖
                                    if(!quxiao)//取消键是不是按下
                                    {   
                                      flag=3;//FLAG等于3
                                      butter=1;//蜂鸣器不响
                                      tt=0;//
                                      num=0;//定时初始0
                                      EA=0;//关中断
                                      lv=0;//绿灯灭
                                      hong=0;//红灯灭
                                    }
                                    while(!quxiao);//取消按键抬开
                                    delay(5);//延时消抖
                                    while(!quxiao);//如果弹开跳出

                            }
                if(flag==4)//如果布防时间到
                      {
                       tt=0;//清计数为0
                       EA=0;//关中断
                       num=0;//记的秒数清零
                       lv=1;//关绿灯
                       flag=5;//flag等于5

                      }        
                    if(hongwai)//如果感应到人黄灯亮
                       huang=1;
                    else  huang=0;//感应不到人黄灯灭

                    if(flag==5)//如果flag等于5
                       {
                         if(hongwai)//如果感应到人
                               {
                                butter=0;//蜂鸣器响
                                EA=1;//开中断
                                }
                       }
                              
             }

}

void time0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
tt++;
if(tt10)
{tt=0; num++;}
if((flag
5)&&(num%20)) // flag = 5 after arming for 15 seconds, num is even light
hong = 1;
if ((flag
5)&&(num%21)) // After 15 seconds of arming, flag = 5, num is an odd number, and light is off. Hong
= 0;
if ((flag
2)&&(num%20)) // flag is equal to 2 after the key is armed, num is an even light and
lv = 1;
if ((flag
2)&&(num%21)) // After the key is armed, the flag is equal to 2, num is an odd number, and the light is off
lv = 0;
if ((flag
2) && (num == 30)) // arming time, num = 30 is 15 seconds, you can change this to achieve arming delay time
flag = 4;
}

Finally, if you have any comments or suggestions, you are welcome to leave a message to me, let us learn together and progress together.
If you need the complete code or design file, please write to me privately, and you will reply as soon as you see it.
Thank you!

Published 97 original articles · 200 praises · 80,000+ views

Guess you like

Origin blog.csdn.net/weixin_44212493/article/details/105072787