51 microcontroller intelligent desk lamp control system simulation (proteus simulation + program + schematic diagram + report + explanation video)

Simulation of intelligent desk lamp control system for infrared photosensitive detection using 51 microcontroller

51 microcontroller infrared photosensitive detection intelligent desk lamp control system simulation (proteus simulation + program + schematic diagram + report + explanation video)

Simulation diagram proteus7.8 and above

Program compiler: keil 4/keil 5

Programming language: C language

Design number: S0050

1. Main functions:

Simulation design of intelligent desk lamp for infrared detection and light detection based on 51 microcontroller

1. Detect the light intensity and display it on the digital tube.

2. It has the function of infrared human body detection.

3. The lighting control mode is divided into automatic mode and manual mode. In automatic mode, the automatic mode indicator light lights up.

4. In automatic mode, the human body is sensed and the LED brightness automatically changes with the light intensity. In manual mode, press the button to control the LED brightness.

5. Software PWM controls LED brightness.

It should be noted that the 51 microcontroller chip in the simulation is universal. AT89C51 and AT89C52 are specific models of the 51 microcontroller, and the cores are compatible. Regardless of stc or at, the pin functions are the same and the program is the same. The chip can be replaced with 51 microcontroller chips such as STC89C52/STC89C51/AT89C52/AT89C51.

2. Simulation

Start simulation

Open the simulation project, double-click the microcontroller in proteus, select the hex file path, and then start simulation. After starting the simulation, the digital tube displays the current light intensity 32 and the brightness level of the LED light 6.

img

Automatic mode:

In automatic mode, the light brightness level changes with the light intensity. The greater the light intensity, the lower the brightness level. When the maximum light intensity is 99, the brightness level is 0, and the lamp beads of the desk lamp are extinguished.

img

In automatic mode, the light brightness level changes with the light intensity. The smaller the light intensity, the higher the brightness level. When the maximum light intensity is 0, the brightness level is 9, and the desk lamp beads are the brightest.

img

In the automatic mode, if the infrared detection does not detect the human body, the lamp beads of the desk lamp will be extinguished regardless of the light intensity.

img

Manual mode:

In manual mode, the desk lamp light brightness is only affected by the brightness switch button and is not affected by light intensity or infrared detection.

img

The above simulation results are in line with the design requirements.

3. Program code

Use keil4 or keil5 to compile, the code has comments, and you can understand the meaning of the code in conjunction with the report.

img

main function

//主函数
void main()
{
    
    
	uchar k=0,i=0;
	uint j=0;
	adc0808_start=0;
	adc0808_oe=0;

	TMOD|=0X01;//初始化定时器
	TH0=0X3C;
	TL0=0XB0;	
	ET0=1;//打开定时器0中断允许
	EA=1;//打开总中断
	TR0=1;//打开定时器
	while(1)
	{
    
    
		

		//显示光照
		P0=0XFF;
		smg3=1;smg2=0;smg1=0;
		P0=smgduan[light/10];
		delay(100);

		P0=0XFF;
		smg3=1;smg2=0;smg1=1;
		P0=smgduan[light%10];
		delay(100);
		//启停指示
		if(start)
		{
    
    
		P0=0XFF;
		smg3=1;smg2=1;smg1=0;
		P0=0xbf;
		delay(100);
		}
		//显示亮度
		P0=0XFF;
		smg3=1;smg2=1;smg1=1;
		P0=smgduan[pwm];
		delay(100);

		if(!k1 &&(k!=1) &&(start==0))//启动
		{
    
    
			k=1;
			start=1;
			fen=set;
			miao=0;
		}
		if(!k2 &&(k!=2))//停止
		{
    
    
			k=2;
			start=0;
		}
		if(!k3 &&(k!=3))//手动,自动
		{
    
    
			k=3;
			mode=!mode;
		}

		if(mode==1)
		{
    
    
		if(!k6 &&(k!=6))//亮度切换
		{
    
    
			k=6;
			if(pwm<9)
				pwm++;
			else
				pwm=1;
		}
		}
		if(k1 && k2 && k3 && k4 && k5 && k6)
			k=0;
		//输出PWM
		if(mode==0)//自动模式
		{
    
    
			led=0;
		if((start==1)&& !ir_in)
		{
    
    
			j=0;
			if(i<9)
				i++;
			else
				i=0;
			if(i<pwm)
				out=0;
			else
				out=1;
		}
		else
		{
    
    
			out=1;
		}
		}
		else//手动模式
		{
    
    
			led=1;
		if(start==1)
		{
    
    
			if(i<9)
				i++;
			else
				i=0;
			if(i<pwm)
				out=0;
			else
				out=1;
		}
		else
		{
    
    
			out=1;
		}
		}
	}
}

4. Schematic diagram

The schematic diagram is drawn with AD, which can be used as a reference for the real thing. The simulation is different from the real thing. If you are inexperienced, don't make it easy.

img

The difference between Proteus simulation and physical works:

1. Running environment: Proteus simulation runs on the computer, while the real thing runs on the hardware circuit board.

2. Debugging method: In Proteus simulation, you can easily perform single-step debugging and observe changes in variable values, while in real objects, you need to debug through a debugger or serial port output.

Circuit connection method: In Proteus simulation, the circuit connection can be modified through software settings, but in the real thing, it needs to be modified through the hardware circuit board and connecting wires.

3. Running speed: Proteus simulation usually runs faster than the real thing, because the simulation is based on computer operation, while the real thing needs to consider factors such as the physical limitations of the circuit board and the response time of the device.

4. Function realization: In Proteus simulation, different functions can be realized through software settings, but in real objects, they need to be realized according to the circuit design and device performance.

5. Design report

6174-word design report

img

6. Design information content list&&download link

Material design materials include simulation, program code, explanation videos, functional requirements, design reports, software and hardware design block diagrams, etc.

0. Common usage problems and solutions – a must-read! ! ! !

1. Simulation diagram

2. Program source code

3. Proposal report

4. Schematic diagram

5. Functional requirements

6. Components list

7. Design report

8. Software and hardware flow chart

9. Explanation video

Altium Designer Software Information

filename.bat

KEIL software information

Proteus software information

Microcontroller learning materials

directory listing.txt

Defense skills

Common descriptions for design reports

Double-click the mouse to open and find more 51 STM32 Microcontroller Course Graduation Project.url

img

Data download link:

https://docs.qq.com/doc/DS3hUb3FHUUZQVWZp

Guess you like

Origin blog.csdn.net/weixin_52733843/article/details/132797046