Share this

Design of an intelligent lighting control system based on STC microcontroller

2026-04-06 05:58:47 · · #1

With the rapid development of today's society and economy, the problem of energy waste is becoming increasingly serious, particularly in areas such as lighting in large underground parking lots, public restrooms, and stairwells. Although incandescent bulbs have many advantages, their low energy efficiency has led to their phase-out by countries around the world. Since Australia took the lead in legislating to phase out incandescent bulbs in 2007, China also released a roadmap for phasing out incandescent bulbs in 2011.

With the phasing out of ordinary incandescent lamps, fluorescent lamps, LEDs, and energy-saving halogen lamps have become the three mainstream lighting fixtures in the current market. Fluorescent lamps are currently the most important and numerous alternative to ordinary incandescent lamps. Although they can save 80% of the energy compared to ordinary incandescent lamps, they are expensive, bulky, have a large luminous area, are not point light sources, have discontinuous spectra, and cannot achieve 100% color rendering. Furthermore, fluorescent lamps contain mercury, phosphors, and a large number of electronic components, and the environmental burden they place on the environment after disposal is immeasurable. In recent years, LEDs have developed very rapidly, but their cost is relatively high, and technically they cannot yet achieve the continuous spectrum of blackbody radiation. In terms of color rendering and color consistency, they still cannot compare with energy-saving halogen lamps, so large-scale adoption is still some distance away. Energy-saving halogen lamps are essentially still incandescent lamps. They are simple in structure, inexpensive, and environmentally friendly. They can operate directly on mains voltage, start instantly, and reach maximum light output immediately. Compared with ordinary incandescent lamps, they can save 30% of electricity. Due to their concentrated light-emitting body that is close to a point light source, the energy-saving halogen lamp has a nearly continuous spectrum of blackbody radiation, 100% color rendering, soft light with a color temperature of around 3000K, and no flicker. In many places with high requirements for lighting quality, they still have unparalleled advantages.

Considering the above factors and in accordance with the requirements of energy saving, emission reduction, intelligence and practicality, the author designed an intelligent lighting control system based on the STC12C5A60S2 microcontroller for energy-saving halogen tungsten lamps. The system utilizes a human infrared pyroelectric sensor and a visible light illuminance sensor to form an environmental detection system, which greatly improves the sensitivity, accuracy and practicality of the lighting control system.

1.1 System Overall Framework

This system uses a microcontroller as the control core and consists of a 5V voltage regulator circuit, a zero-crossing detection circuit, a human infrared pyroelectric sensor module, a visible light illuminance sensor module, a lighting driver circuit, and a serial port debugging module. The system block diagram is shown in Figure 1.

1.2 System Working Principle

A human infrared pyroelectric sensor is used to detect human features, and a visible light illuminance sensor detects the current ambient light level. The sensor signals are sent to a microcontroller for processing. Based on the processing results, the microcontroller controls the on/off state and brightness of the lights during each interrupt. A serial port debugging module serves as a human-computer interaction tool, facilitating the observation of relevant system parameters.

2 System Hardware Design

2.15V voltage regulator circuit

The low-voltage power supply of this system is introduced from a 220V-9V transformer, which passes through a rectifier bridge to obtain a 9V DC power supply. Then, a three-terminal linear regulator chip LM7805 is used to obtain a 5V DC power supply. The schematic diagram of the 5V voltage regulator circuit is shown in Figure 2.

2.2 Minimum System of Microcontroller

The STC12C5A60S2AD series microcontroller is a single-clock/machine-cycle (IT) microcontroller manufactured by STC Technology. It is a new generation 8051 microcontroller characterized by high speed, low power consumption, and strong anti-interference capabilities. Its instruction code is fully compatible with the traditional 8051, but it offers high-speed 10-bit A/D conversion, making it suitable for motor control and high-interference applications. Its minimum system consists of a reset circuit and a crystal oscillator circuit. The schematic diagram of the microcontroller's minimum system is shown in Figure 3.

2.3 Zero-crossing detection circuit

The voltages of diodes D2 and D3 are taken from the secondary winding of a 220V-9V transformer. After full-wave rectification, a pulsating DC voltage waveform is formed. This waveform is then divided by resistors and filtered by capacitors to form the base voltage waveform of the transistor. When the base voltage is below 0.7V, the transistor is cut off; conversely, it is turned on. The collector of the transistor is pulled up by resistor R4 to form a high level. Through the repeated switching on and off of the transistor, a 100Hz pulse level is output at the collector, which is used for the microcontroller's falling edge interrupt. The schematic diagram of the zero-crossing detection circuit is shown in Figure 4.

2.4 Human Infrared Pyroelectric Sensor Module

The human body has a constant body temperature, generally around 37 degrees Celsius, and therefore emits infrared radiation with a specific wavelength of about 10 μm. A human infrared pyroelectric sensor can detect the infrared radiation emitted by the human body in a non-contact manner. By installing a Fresnel lens on it, the pyroelectric infrared signal can be refracted (reflected) onto the infrared pyroelectric sensor. This also divides the detection zone into several bright and dark areas, so that moving objects entering the detection zone will generate changing pyroelectric infrared signals on the infrared pyroelectric sensor in the form of temperature changes. In this way, the infrared pyroelectric sensor can generate changing electrical signals.

The human infrared pyroelectric sensor element in this system uses the HC-SR501, with the BISS0001 integrated chip and corresponding external resistors and capacitors forming the sensor's signal processing circuit. Pin 1 of the BISS0001 is connected to a high level, setting the circuit to be repeatedly triggered. The output delay time can be adjusted by changing the value of R11. The human infrared pyroelectric sensor converts the changes in sensed infrared radiation energy into an electrical signal, which is output through pin 2 of the BISS0001. When someone is moving within the warning zone, the module outputs a 3.3V voltage; when no one is present, the module outputs a low level. Experiments show that the module can sense up to 8 meters at its maximum range and 110° at its maximum angle. The schematic diagram of the human infrared pyroelectric sensor module is shown in Figure 5.

2.5 Visible Light Illuminance Sensor Module

The visible light illuminance sensor uses the ON9658, which is an integrated optoelectronic sensor with a typical incident wavelength of 520nm. It is highly sensitive in the visible light range and has a built-in dual-sensor receiver, micro-signal CMOS amplifier, high-precision voltage source and correction circuit. The output current changes linearly with illuminance and has good temperature stability.

Since the sensor's output signal is a sine wave with a peak value varying with illuminance, a hardware detection circuit consisting of a Schottky diode and resistive-capacitive components is used to obtain the peak value of the sensor's output voltage. Finally, a DC voltage signal with an amplitude equal to the peak value of the sine wave is output. The schematic diagram of the visible light illuminance sensor module is shown in Figure 6.

2.6 Lighting Lamp Driver Circuit

The lighting driver circuit mainly consists of a 250V bidirectional optocoupler MOC3021 and a bidirectional thyristor BT136. R7 and R8 are connected in series to form the gate resistor of the bidirectional thyristor. When the bidirectional thyristor has high sensitivity, its gate impedance is also high; adding these two resistors improves anti-interference capability. R8 and C6 form a surge absorption circuit to prevent surge voltage from damaging the bidirectional thyristor. A lighting control signal is output from one I/O port of the microcontroller, triggering the optocoupler MOC3021 to control the on/off state of the bidirectional thyristor BT136, thus controlling the switching and brightness of the lighting lamp. The lighting driver circuit is shown in Figure 7.

2.7 Serial Port Debugging Module

The serial port debugging module of this system uses RS-232 serial communication, with a maximum transmission distance of 50 feet and a maximum transmission rate of 20kbps. It can achieve bidirectional transmission and full-duplex communication. Because the digital quantities transmitted on RS-232 use negative logic and are only symmetrical with ground, a level conversion chip MAX232 is required when connecting it to a microcontroller.

3 System Software Design

The system software is programmed in C language and adopts a modular design approach. It comprises four modules centered around the main program: an A/D conversion program, an I/O port output lighting control program, a serial port transmission program, and interrupt functions. The flowcharts for the main program and interrupt functions are shown in Figures 9 and 10, respectively.

3.1 Main Program

After the system starts working, the main program first initializes the system functions, starts the watchdog timer to prevent unexpected program crashes, and then enables falling edge interrupts. Next, it calls the functions of each functional module in a loop and executes the watchdog timer feeding program.

3.2 A/D Conversion Program

The A/D conversion program is mainly used for converting the detection signals of human infrared pyroelectric sensors and visible light illuminance sensors. Each time the main program calls the corresponding A/D conversion program for each sensor, it converts the analog signal of the detected signal into a corresponding digital signal for use by other programs.

3.3 I/O Port Output Lighting Control Program

The main function of this program module is to receive digital signals from two sensors after A/D conversion, and then calculate the off-time of the lighting lamp within one cycle based on the system's set rules, which is then used by the interrupt function. In the main program flowchart, T represents the off-time of the lighting lamp within one cycle, and X represents the detection signal from the visible light illuminance sensor.

3.4 Serial Port Transmission Program

The serial port sending program transmits the detection signals from the two sensors to the host computer, facilitating the observation of actual parameters and software debugging.

3.5 Interrupt Functions

The interrupt function uses the off time T of the light within an interrupt cycle obtained from the main program to control the switching on and off and the brightness of the light.

4. Conclusion

This intelligent lighting control system, designed with energy conservation and emission reduction in mind, utilizes energy-saving halogen tungsten lamps as lighting sources, primarily addressing the serious problem of wasted electricity in public lighting. This system achieves excellent lighting, energy saving, and environmental protection effects. It eliminates the nuisance problem of traditional voice-activated lights and solves the energy-saving issue of controlling the on/off state and brightness of lights. Experimental verification has shown that the system is small in size, stable in operation, error-free, and highly automated, making it a highly practical intelligent lighting control system.

Read next

CATDOLL CATDOLL 115CM Shota Doll Kiki Male Doll

Height: 115cm Male Weight: 19.5kg Shoulder Width: 29cm Bust/Waist/Hip: 57/53/64cm Oral Depth: 3-5cm Vaginal Depth: N/A ...

Articles 2026-02-22