日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

B005 – 基于STC8的单片机智能路灯控制系统

發布時間:2023/12/29 windows 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 B005 – 基于STC8的单片机智能路灯控制系统 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

任務詳情

基于單片機的智能路燈控制系統

  • 非節能模式下LED燈同時亮滅,凌晨0點——6點為節能模式,該模式下只亮LED燈
    中的一部分。當有聲響時則開啟全部LED燈,延遲1分鐘后重新變為一半LED燈處于點亮的狀態。
  • 時間功能:夏季19: 00———23∶00期間路燈常亮,冬季18:00———23∶00期間路燈常亮。
  • 非設置時間段,系統通過檢測光線強度和聲響,在黑暗時若有聲響則啟動路燈,路燈延
    遲1分鐘后自動關閉。
  • 使用光敏電阻檢測路燈的故障情況,在路燈符合條件正常開啟的情況下,若此時沒有檢
    測到光線則啟動蜂鳴器報警,故障短信提醒(GSM模塊),并設置緊急故障處理按鈕。
  • LCD屏幕用作公告屏,顯示公益信息以及一些商業廣告
  • 效果


    功能設計資料

    源代碼

    /******************************************************************************** 文件名稱:基于STC8的單片機智能路燈控制系統* 實驗目的:1.* 2.* 程序說明:完整程序Q:2772272579;@: itworkstation@hotmail.com* 日期版本:基本設計如下,可定制。*******************************************************************************/ #include"config.h" void check_light(void); void key_test(void);sbit GMLight_gpio= P1^0; sbit GM_gpio= P1^4; sbit BEEP_gpio = P3^3; sbit SY_gpio = P3^4; sbit key01_gpio = P3^5; void GPIO_config(void) {P1M1 &= ~(1<<0); //設置成準雙向IOP1M0 &= ~(1<<0);P1M1 &= ~(1<<4); //設置成準雙向IOP1M0 &= ~(1<<4);P3M1 &= ~(1<<3); //設置成推挽輸出P3M0 |= (1<<3);P3M1 &= ~(1<<4); //設置成準雙向IOP3M0 &= ~(1<<4);P3M1 &= ~(1<<5); //設置成準雙向IOP3M0 &= ~(1<<5); } /*************************************************************************主函數 **************************************************************************/ bit flag_jieneng=0,flag_on=0; //節能模式 bit flag_on_time=0;uchar GuangGao=0; uint LCD_count01=0; bit flag_distime=0; void main (void) { int ret=0; //GSM信號提示uchar i=0;Proc_Init();GPIO_config();LED_Init(); //LED燈函數初始化LED_Control(LED_ALL,ON);Ds1302Init();UART3_Init();UART4_Init();BEEP_gpio=0;Delay_ms(1000); BEEP_gpio=1; LED_Control(LED_ALL,OFF);printf("CLR(%hd);DIR(3);SBC(%hd);FSIMG(2097152,0,0,376,240,1);\r\n",LCD_ColorStructure.LCD_BackColor,LCD_ColorStructure.LCD_SBCColor); USART4_CheckBusy(); printf("CLR(%hd);DIR(3);SBC(%hd);FSIMG(2277632,0,0,376,240,0);\r\n",LCD_ColorStructure.LCD_BackColor,LCD_ColorStructure.LCD_SBCColor); USART4_CheckBusy(); printf("DCV32(124,8,'初始化界面',%hd);\r\n",LCD_ColorStructure.LCD_TextColor);USART4_CheckBusy();printf("DCV32(12,40,'制作人:***',%hd);\r\n",LCD_ColorStructure.LCD_TextColor); USART4_CheckBusy(); printf("DCV32(12,72,'制作單位:****',%hd);\r\n",LCD_ColorStructure.LCD_TextColor); USART4_CheckBusy(); Timer0_Init(20);printf("DCV32(12,200,'GSM:',%hd);\r\n",LCD_ColorStructure.LCD_TextColor); USART4_CheckBusy(); for(i = 0;i < STABLE_TIMES;i++)//等待GSM網絡穩定{delay_20ms(1);printf("DCV32(108,200,'等待網絡%bu ',%hd);\r\n",i,LCD_ColorStructure.LCD_TextColor); USART4_CheckBusy(); }printf("DCV32(108,200,'檢查配置 ',%hd);\r\n",LCD_ColorStructure.LCD_TextColor); USART4_CheckBusy(); ret = check_status(); //初始化配置 if(ret == 1){printf("DCV32(108,200,'通信成功 ',%hd);\r\n",LCD_ColorStructure.LCD_TextColor); USART4_CheckBusy(); delay_ms(2000);ret = config_format();//配置if(ret == 1){printf("DCV32(108,200,'配置成功 ',%hd);\r\n",2); USART4_CheckBusy(); delay_ms(2000);}else{printf("DCV32(108,200,'配置失敗 ',%hd);\r\n",1); USART4_CheckBusy(); delay_ms(2000);}}else{printf("DCV32(108,200,'通信失敗 ',%hd);\r\n",1); USART4_CheckBusy(); delay_ms(2000);}CLR_Buf();//清空串口數組,準備接收 GSM信息 printf("DCV32(108,200,'結束配置 ',%hd);\r\n",LCD_ColorStructure.LCD_TextColor); USART4_CheckBusy(); while (1) //主循環{key_test();if(Flag_Time_Ms(200)){LCD_count01++;if(LCD_count01>20)//切換時間{LCD_count01=0;GuangGao++;if(GuangGao>5){GuangGao=0;flag_distime=0;}if(GuangGao==0){printf("CLR(%hd);DIR(3);SBC(%hd);FSIMG(2097152,0,0,376,240,1);\r\n",LCD_ColorStructure.LCD_BackColor,LCD_ColorStructure.LCD_SBCColor); USART4_CheckBusy(); }else if(GuangGao==1){printf("CLR(%hd);DIR(3);SBC(%hd);FSIMG(2458112,0,0,376,240,1);\r\n",LCD_ColorStructure.LCD_BackColor,LCD_ColorStructure.LCD_SBCColor); USART4_CheckBusy(); }else if(GuangGao==2){printf("CLR(%hd);DIR(3);SBC(%hd);FSIMG(2638592,0,0,376,240,1);\r\n",LCD_ColorStructure.LCD_BackColor,LCD_ColorStructure.LCD_SBCColor); USART4_CheckBusy(); }else if(GuangGao==3){printf("CLR(%hd);DIR(3);SBC(%hd);FSIMG(2819072,0,0,376,240,1);\r\n",LCD_ColorStructure.LCD_BackColor,LCD_ColorStructure.LCD_SBCColor); USART4_CheckBusy(); }else if(GuangGao==4){printf("CLR(%hd);DIR(3);SBC(%hd);FSIMG(2999552,0,0,376,240,1);\r\n",LCD_ColorStructure.LCD_BackColor,LCD_ColorStructure.LCD_SBCColor); USART4_CheckBusy(); }else{ flag_distime=1; }}Ds1302ReadTime(); if(flag_distime) {LCD_Display();} if(TIME[2]<6){flag_jieneng=1;}else{flag_jieneng=0;}if(TIME[4]<8) //前八個月{if(TIME[2]>=19 && TIME[2]< 23){flag_on_time=1;} else{flag_on_time=0;}}else //后四個月{if(TIME[2]>=18 && TIME[2]< 23){flag_on_time=1;} else{flag_on_time=0;}} }if(flag_jieneng && SY_gpio==0) //夜間節能模式識別到聲音{flag_shengyin=1;} if(flag_jieneng) //節能模式{flag_GMSY=0;if(flag_shengyin){LED_Control(LED_ALL,ON);}else{LED_Control(1,ON);LED_Control(3,ON);LED_Control(5,ON);LED_Control(2,OFF);LED_Control(4,OFF);}check_light();}else if(flag_on_time) //夏季,冬季全亮時間{flag_GMSY=0;LED_Control(LED_ALL,ON);check_light();}else //其他時間段{if(GM_gpio==1 && SY_gpio==0)//亮度較暗為高電平 有聲響為低電平{flag_GMSY=1;}else{if(flag_GMSY==0){BEEP_gpio=1;LED_Control(LED_ALL,OFF);}}if(flag_GMSY==1){LED_Control(LED_ALL,ON);check_light();} else{BEEP_gpio=1;LED_Control(LED_ALL,OFF);}} } } bit flag_senderro=0; void check_light(void) {if(GMLight_gpio==0) //檢查該亮燈時有沒有亮{BEEP_gpio=1;flag_senderro=0; }else //沒有的話,報警{BEEP_gpio=0;if(flag_senderro==0){flag_senderro=1;//發送一次報警信息 // send_text_message_set("There seems to be something wrong with the street lamp. Please check it in time!!!");}} } void key_test(void) {if(key01_gpio==0){Delay_ms(10);if(key01_gpio==0){if(BEEP_gpio==0) //如果本來就處于報警模式{BEEP_gpio=1;}else //否則進行測試模式{do{LED_Control(LED_ALL,OFF);check_light();BEEP_gpio=0;send_text_message_set("There seems to be something wrong with the street lamp. Please check it in time!!!");}while(key01_gpio==0);BEEP_gpio=1;}// send_text_message_set("There seems to be something wrong with the street lamp. Please check it in time!!!"); // while(key01_gpio==0); }} } /*******************************************************************/

    總結

    以上是生活随笔為你收集整理的B005 – 基于STC8的单片机智能路灯控制系统的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。