#include "STC89C51RC.H"
sbit DQ = P4^3;
sbit SPK = P1^0;
#include
#define seg1 XBYTE[0xffec]
#define seg2 XBYTE[0xffed]
#define seg3 XBYTE[0xffee]
#define seg4 XBYTE[0xffef]
unsigned char IRMcode[4];
unsigned char code ledmap[]= //Common cathode LED digital tube decoding table
{
0x3f,0x06,0x5b,0x4f,0x66, //0,1,2,3,4,
0x6d,0x7d,0x07,0x7f,0x6f, //5,6,7,8,9,
0x77,0x7C,0x39,0x5E,0x79, //A,b,C,d,E,
0x71, //F,
};
void delay(unsigned int);
void main()
{
EA = 1;
EX2 = 1;
while(1)
{
if (IRMcode[2]==~IRMcode[3]){
seg1 = ~ledmap[IRMcode[2]/100];
seg2 = ~ledmap[IRMcode[2]/10%10];
seg3 = ~ledmap[IRMcode[2]%10];
seg4 = 0xff;//熄灭
}
}
}
void Sound(void)
{
SPK = 0;
delay(10000);
SPK = 1;
}
void IRMint(void) interrupt 6 using 2
{
unsigned char count;
unsigned int count1;
unsigned char i,j;
EA = 0;
count = 9;
while(--count)
{
delay(100);//440us
if(DQ){EA = 1;return;}
}
while(DQ==0);//Through the remaining low level of the boot code
//The above completes the 4.5ms low level detection of the boot code
count = 9;
count1 = 0;
while(--count)
{
delay(100);//440us
if(DQ==0){EA = 1;return;}
}
while(DQ==1)//Through the remaining high level of the boot code
{
if(count1++>1000) {
P1=0x55;EA = 1;return;}
}
//The above completes the 4.5ms high level detection of the boot code
count1 = 0;
for(j=0;j<4;j++)//setting the number of valid bytes
{
for(i=0;i<8;i++)//number of byte bits
{
while(DQ==0);//pass the low level of encoding
delay(200);//delay to determine the length of maintaining the high level of encoding
IRMcode[j]<<=1;
if(DQ)IRMcode[j]|=0x01;
while(DQ==1){//pass the remaining high level of encodingif
(count1++>2000){EA = 1;return;}
}
}
}
Sound();
EA = 1;
}
//General delay function
//22.1184,10 = 48.4 us (5us+43.4)
//22.1184,100 = 439 us (43.4*10+5)
//22.1184,1000 = 4345 us(43.4*100+5)
//22.1184,10000 = 43450 us(43.45*1000+5)
void delay(unsigned int t)
{
while(--t);
}
Previous article:Application of single chip microcomputer in stress magnetic measurement device
Next article:Design of infrared remote control decoder
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
- EEWORLD University Hall----Live Replay: Microchip Security Series 15 Simplifies Security Application Design with dsPIC33/PIC24 and ATECC608 Devices
- EEWORLD University - Designing Wide Input DC/DC Converters for Thermostat Applications
- Win a JD.com card! Check in at Infineon's new SiC MOSFET pop-up store
- System Antenna Design Method Based on Characteristic Mode Theory
- Active crystal oscillator waveform problem
- Multi-cell lithium battery charging management solution-TPS54201 application in sweeping robot
- RT-Thread uses printf or rt_kprintf function for serial port printing
- IoT Basics: Important Information for Today and Tomorrow
- [Erha Image Recognition Artificial Intelligence Vision Sensor] 3. General Settings and Face Recognition
- Prize-winning quiz: Find the "know-it-all" expert on Intel Vision Accelerated Design online