Simulation design based on STM32 intelligent curtain control system (including source program + proteus simulation + explanation video)

# Based on STM32 intelligent curtain design (including source program + proteus simulation)

Simulation: proteus8.11
Program compiler: keil 5
Programming language: C language
No. C0007
data download link

Explainer video

Simulation design of simple intelligent curtain control system based on STM32

Function Description:

Implementation function:

There are two modes: manual and automatic

In automatic mode, the sliding rheostat simulates a light sensor and is detected and compared with the threshold through stm32

Open the curtains if the threshold is below the threshold and close the curtains if the threshold is above the threshold.

In manual mode, the buttons control the closing and opening of the curtains

Simulation diagram (source file provided):

new version:

new cover

Old version:

Insert image description here

Source program (source files provided):

#include "delay.h"
#include "sys.h"
#include "adc.h"
#include "1602.h"
#include "motor.h"
#include "bsp_dht11.h"
#define LED1 PAout(13)
#define LED2 PAout(14)
#define MOTOR PCout(0)

unsigned char dis_vol1[] = {
    
    "LUX:      % auto"};
unsigned char dis_vol2[] = {
    
    "  auto"};
unsigned char dis_vol3[] = {
    
    "manual"};
//函数声明
void display1(void);
void display2(void);
u16    LUX, HZ;
int main(void)
{
    
    
    unsigned int i;
    u16 ADCValue1, ADCValue2;
    float voltage1, voltage2;
    u8 Mflag = 2;
    u8 OPENflag = 0;	//起初代表窗帘关
    u8 AUTOflag = 0;	//起初代表自动
    delay_init();
    Adc_Init();
    GPIO_InitStructReadtempCmd();
    MotoR_GPIO();
    lcd_system_reset();
    LED1 = 1;
    LED2 = 0;
    MOTOR = 1;
    while(1)
    {
    
    
        ADCValue1 = Get_Adc_Average(ADC_Channel_0, 10);
        voltage1 = ((float)ADCValue1 / 4096) * 3.3; //计算电压
        LUX = (10000 * voltage1) / 33;
        display1();
        if(PCin(12) == 0) //自动
        {
    
    
            AUTOflag = 0;


            for(i = 0; i <6; i++)
                lcd_char_write(i, 1, dis_vol2[i]);
        }
        if(PCin(13) == 0) //手动
        {
    
    
            AUTOflag = 1;
            for(i = 0; i < 6; i++)
                lcd_char_write(i, 1, dis_vol3[i]);
        }
        if(PCin(10) == 0 && OPENflag == 0 && AUTOflag == 1)
        {
    
    
            LED1 = 0;
            LED2 = 1;
            MOTOR = 0; //开窗帘
            Mflag = 2;
            OPENflag = 1;	 //已经开好
        }
        if(PCin(11) == 0 && OPENflag == 1 && AUTOflag == 1)
        {
    
    
            LED1 = 1;
            LED2 = 0;
            MOTOR = 1; //关闭窗帘
            Mflag = 2;
            OPENflag = 0;	 //已经关好

        }
        if(LUX > 400) //40%  阈值
        {
    
    
            display1();
            Mflag = 1;		//光照足够,关闭窗帘
        }
        else
        {
    
    
            display1();
            Mflag = 0;	//光照不足,需要启动窗帘
        }
        if(Mflag == 1 && OPENflag == 1 && AUTOflag == 0)
        {
    
    
            LED1 = 1;
            LED2 = 0;
            MOTOR = 1; //关闭窗帘
            Mflag = 2;
            OPENflag = 0;	 //已经关好
        }
        else if(Mflag == 0 && OPENflag == 0 && AUTOflag == 0)
        {
    
    
            LED1 = 0;
            LED2 = 1;
            MOTOR = 0; //开窗帘
            Mflag = 2;
            OPENflag = 1;	 //已经开好

        }
    }
}

void display1()
{
    
    
    unsigned int i, j;
    dis_vol1[5] = LUX / 100 + 0x30;
    dis_vol1[6] = LUX % 100 / 10 + 0x30;
    dis_vol1[7] = '.';
    dis_vol1[8] = LUX % 10 + 0x30;
    for(i = 0; i < 12; i++)
        lcd_char_write(i, 0, dis_vol1[i]);
    //  	 for(j=0;j<15;j++)
    // 	  lcd_char_write(j,1,dis_vol2[j]);
}


Insert image description here

The information list is as follows:

Download method: watch the video or the beginning of the article
New information list

Guess you like

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