Design of infrared electronic password lock based on 51 single chip microcomputer

Publisher:SereneHarmonyLatest update time:2020-09-24 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

This design includes two 51 single-chip microcomputers and an infrared component IRLINK that comes with proteus to simulate infrared communication: 1) A single-chip microcomputer simulates sending password signals;         
2) A single-chip microcomputer receives password signals and controls the opening or closing of the lock through the electromagnetic coil;
3) Use the transmitter of the infrared component IRLINK that comes with proteus to simulate the first single-chip microcomputer transmitting infrared signals;
4) Use the receiver of the infrared component IRLINK that comes with proteus to simulate receiving infrared signals and convert them into electrical signals through photoelectric conversion and send them to the second single-chip microcomputer (controller of infrared electronic password lock)

The following is the design of the circuit diagram:

Circuit diagram designCircuit diagram design

simulation

The following is part of the infrared communication program

#include "reg52.h" //This file defines some special function registers of the microcontroller

        

typedef unsigned int u16; //declare and define the data type

typedef unsigned char u8;


sbit LOCK=P2^0; //Unlock control interface


sbit IRIN=P3^2; //Interface between infrared communication and MCU, controlled by external interrupt 0


u8 IrValue[4]; //Actually only 4 bits are used

u8 code1=0x00; //Store the original lock password: 00000000;

u8 code2=0xff; //Store the original unlocking password: 111111111;

u8 Time; //Store intermediate variables


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

* Function name: delay

* Function: Delay function, when i=1, the delay is about 10us

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

void delay(u16 i)

{

        while(i--);        

}



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

* Function name: IrInit()

* Function: Initialize infrared reception

* Input : None

* Output: None

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


void IrInit()

{

        IT0=1; //Falling edge trigger

        EX0=1; //Enable interrupt 0

        EA=1; //Open the general interrupt

        IRIN=1; //Initialize port

}



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

* Function name: main

* Function: Main function

* Input: None

* Output: None

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

void main()

{        

        IrInit();

        

        while(1)

        {        

          if(IrValue[2] == code1) LOCK=1; //Close the door

          if(IrValue[2] == code2) LOCK=0; //Open the door

        }               

}


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

* Function name: ReadIr()

* Function: Interrupt function to read infrared value

* Input : None

* Output: None

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


void ReadIr() interrupt 0

{

        u8 j,k;

        u16 err;

        Time=0;                                         


         . . . . .



Reference address:Design of infrared electronic password lock based on 51 single chip microcomputer

Previous article:How the serial port works
Next article:51 single chip microcomputer DS18B20 temperature sensor

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号