Main functions of intelligent aisle lighting system
⑴The system is equipped with 2 key function keys (mode switch key and power key), and a microcontroller reset key;
(2) The system is equipped with 1 power indicator light and 5 status indicator lights, namely: light detection signal indicator light (the indicator light is on when the light is dark), infrared pyroelectric sensor signal indicator light (the indicator light is on when the human body signal is detected), automatic mode relay working status indicator light (in automatic mode, the relay is connected and the indicator light is on), mode indicator light (in manual mode, the indicator light is on), manual mode relay working status indicator light (in manual mode, the relay is connected and the indicator light is on);
⑶ The system has two working modes: automatic working mode and manual working mode. The default mode is automatic mode when it is turned on, and the mode can be switched through the "mode switch key";
⑷ In automatic mode, the relay on time is controlled by the delay variable. When the delay variable is > 0, the relay is on, and when the delay variable is = 0, the relay is off. The delay variable is controlled by the detected signal. When the light is dark and someone is detected, the delay variable is equal to the set delay time, so that the light bulb automatically turns off after a period of time after the person leaves, which saves energy.
⑸The set delay time can be modified. In automatic mode, long press the "power key". Every 5 seconds, the delay time will increase by 10 seconds, and 5 status indicators will be displayed, one indicator light from left to right every 5 seconds. The maximum delay time is 50 seconds.
⑹ In manual mode, the relay switch can be controlled by the "on/off key";
The microcontroller source program is as follows:
#include #include #define uchar unsigned char #define uint unsigned int sbit renti=P2^1; //Define human feeling sbit guangming=P2^0; //define the light detection pin sbit jdq=P2^7; //relay sbit L1=P2^6; //define indicator light sbit L2=P2^5; sbit L3=P2^4; sbit L4=P2^3; sbit L5=P2^2; sbit K1=P1^0; //define switch sbit K2=P1^1; int count;rt,gm,qd,shijian,sj=10,moshi=1,shijian1,count1,shezhi=0; //variables void qudou(void) //debounce delay { int i; for(i=0;i<2400;i++); } void key() //Key scan {if(K1==0) //debounce { qudou(); if(K1==0) //Mode button is pressed {moshi++; //moshi=1 is automatic, =0 is manual if(moshi>=2) moshi=0; jdq=1; }while(K1==0); } if(moshi==1) //in automatic mode {if(K2==0) //Switch button pressed { qudou(); if(K2==0) {shezhi=1; //Long press the switch button to set the delay time, see the interrupt shijian1=0; }while(K2==0); } else shezhi=0; //Exit the setting without pressing the switch button } } void rentijiance() //Infrared human body detection subroutine { if(renti==0) rt=1; //When no human body is detected, the sensor sends a low level to the microcontroller, and rt is 1 rt=0 (someone), rt=1 (no one) else rt=0; } void guangzhaoqiangdu() //Light intensity subroutine { if(guangming==0) gm=1; //When the light is bright, the sensor sends a low level to the microcontroller, and gm is 1 gm=0 (dark light), gm=1 (bright light) else gm=0; } void panduan() //judgment {if(moshi==1) {if(gm==0) {if(rt==0) shijian=sj; else shijian=shijian;} else shijian=shijian; } else shijian=0; } void zhishideng() //Indicator light function {L5=gm; L4=rt; if(moshi==1) L3=jdq; else L3=1; L2=moshi; if(moshi==0) L1=jdq; else L1=1; } void qudong() //Relay drive {if(moshi==1) //In automatic mode {if(shijian>0) jdq=0; //Control the relay according to the delay time else jdq=1; } else //In manual mode {if(K2==0) { qudou(); if(K2==0) //Turn on the switch to control the relay {jdq=!jdq; }while(K2==0); } } } void main() //Main program { TMOD=0x1; //Interrupt enabled TH0=0xb1; TL0=0xe0; TR0=1; ET0=1; EA=1; while(1) // infinite loop {key(); //Key scan rentijiance(); //Human body guangzhaoqiangdu(); //lighting panduan(); //judgment zhishideng(); //Indicator light qudong(); //Driver } } void time0(void) interrupt 1 //interrupt { TH0=0xb1; TL0=0xe0; if(shijian>0) // used to time delay { count++; if(count==50) { count=0; shijian--; } } if(shezhi==1) //Used to set the delay time in automatic mode {count1++; if(count1==50) { count1=0; shijian1++; if(shijian1<=5) //Press and hold for 5 seconds, the delay time is 10s, and there is 1 indicator light {sj=10; L5=0;L4=1;L3=1;L2=1;L1=1;} else if(shijian1<=10) //Press and hold for 10 seconds, the delay time is 20s, and there are 2 indicator lights {sj=20; L5=0;L4=0;L3=1;L2=1;L1=1;} else if(shijian1<=15) //Press and hold for 15 seconds, the delay time is 30 seconds, and there are 3 indicator lights {sj=30; L5=0;L4=0;L3=0;L2=1;L1=1;} else if(shijian1<=20) //Press and hold for 20 seconds, the delay time is 40s, and there are 4 indicator lights {sj=40; L5=0;L4=0;L3=0;L2=0;L1=1;} else if(shijian1>25) //Press and hold for 25 seconds, the delay time is 50s, and 5 indicator lights are displayed {sj=50; L5=0;L4=0;L3=0;L2=0;L1=0;} } } }
Previous article:LCD12864 key menu setting with Chinese character library, single chip microcomputer experimental program
Next article:51 single chip microcomputer controls stepper motor and DC reduction motor
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
- Power supplies with digital control
- Please advise, brothers.
- One year's work equals three years' work? TSMC engineer shows off 2.5 million yuan bonus
- Evaluation summary: Mil based on NXP's first NPU kit MYC-JX8MPQ
- How to choose a suitable water level sensor?
- Can someone help me think of a microcontroller project?
- Development of User Graphical Interface (GUI) for Digital Oscilloscope Based on DSP
- [Xianji HPM6750 Review] + Software simulation IIC reads the temperature and humidity sensor values
- In fact, Valentine's Day 20200214 was cancelled
- This problem occurs when setting up the stm8 environment. What is the reason? Thank you