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 design
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;
. . . . .
Previous article:How the serial port works
Next article:51 single chip microcomputer DS18B20 temperature sensor
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Solving for the transfer characteristic curve of an op amp
- What does the typical transmission distance of an infrared receiver mean?
- GD32307E-START power on + led control
- Common options for compiling c6x
- [Silicon Labs BG22-EK4108A Bluetooth Development Evaluation] Evaluation 3: Try Keil/IAR Development
- Today at 10:00 AM Live: Comprehensive explanation of TI MSP Academy tutorial
- Overview of TI's 28335 chip
- 【STM32WB55 Review】+First Impressions
- The Relationship between DSP and FPGA in Embedded Development
- DSP Learning (4) Bus Structure