当前位置:网站首页>B005 - STC8 based single chip microcomputer intelligent street light control system
B005 - STC8 based single chip microcomputer intelligent street light control system
2022-08-01 17:58:00 【A small project member】
任务详情
An intelligent street light control system based on single chip microcomputer
- in non-power saving modeLED灯同时亮灭,凌晨0点——6Click to save power mode,Only light in this modeLED灯
中的一部分.Turn on all when there is a soundLED灯,延迟1It becomes half again after a few minutesLEDThe light is on. - 时间功能:夏季19: 00———23∶00During this period, the street lights are always on,冬季18:00———23∶00During this period, the street lights are always on.
- non-set time period,The system detects light intensity and sound,Turn on the street lights if there is a sound when it is dark,street lamp extension
迟1分钟后自动关闭. - Use photoresistors to detect fault conditions in street lights,When the street lights meet the conditions and turn on normally,If not checked at this time
When light is detected, a buzzer alarm will be activated,Fault SMS reminder(GSM模块),And set the emergency troubleshooting button. - LCDThe screen is used as an announcement screen,Display non-profit information and some commercials
效果


Functional design information

源代码
/******************************************************************************* * 文件名称:基于STC8The single-chip intelligent street light control system * 实验目的:1. * 2. * 程序说明:完整程序Q:2772272579;@: [email protected] * 日期版本:基本设计如下,可定制. *******************************************************************************/
#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); //Set to quasi-bidirectionalIO
P1M0 &= ~(1<<0);
P1M1 &= ~(1<<4); //Set to quasi-bidirectionalIO
P1M0 &= ~(1<<4);
P3M1 &= ~(1<<3); //设置成推挽输出
P3M0 |= (1<<3);
P3M1 &= ~(1<<4); //Set to quasi-bidirectionalIO
P3M0 &= ~(1<<4);
P3M1 &= ~(1<<5); //Set to quasi-bidirectionalIO
P3M0 &= ~(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(); //LEDLight function initialization
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 //the next four months
{
if(TIME[2]>=18 && TIME[2]< 23)
{
flag_on_time=1;
}
else
{
flag_on_time=0;
}
}
}
if(flag_jieneng && SY_gpio==0) //The night energy saving mode recognizes the sound
{
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) //夏季,Winter full light time
{
flag_GMSY=0;
LED_Control(LED_ALL,ON);
check_light();
}
else //其他时间段
{
if(GM_gpio==1 && SY_gpio==0)//Brightness is dim to high level There is a low level sound
{
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) //Check if this light is on when it is on
{
BEEP_gpio=1;
flag_senderro=0;
}
else //没有的话,报警
{
BEEP_gpio=0;
if(flag_senderro==0)
{
flag_senderro=1;
//Send an alarm message once
// 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) //If it is already in alarm mode
{
BEEP_gpio=1;
}
else //Otherwise go to test mode
{
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);
}
}
}
/*******************************************************************/
边栏推荐
猜你喜欢

创造建材数字转型新视界,中建材如何多边赋能集团业务快速发展

关于Mysql服务无法启动的问题

B002 - Embedded Elderly Positioning Tracking Monitor

XAML WPF项目groupBox控件

SRM供应商管理系统如何助力口腔护理企业实现采购战略的转型升级

【Day_09 0427】走方格的方案数

RecSys'22|CARCA: Cross-Attention-Aware Context and Attribute Recommendations

阿里云的域名和ip绑定

GRUB2的零日漏洞补丁现已推出

QPalette palette, frame color fill
随机推荐
When custom annotations implement log printing, specific fields are blocked from printing
LeaRun.net快速开发动态表单
opencv基本的图像处理
SQL函数 TO_CHAR(一)
机器学习快速入门
广汽埃安“弹匣电池”,四大核心技术,出行安全保障
基于ORB-SLAM2的改进代码
【Day_10 0428】密码强度等级
深入分析类加载器
EpiSci|片上系统的深度强化学习:神话与现实
DBPack SQL Tracing 功能及数据加密功能详解
小贝拉机器人是朋友_普渡科技召开新品发布会,新一代送餐机器人“贝拉”温暖登场...
【Day_11 0506】求最大连续bit数
食品安全 | 新鲜食品vs速食食品,哪一种是你的菜?
主流小程序框架性能分析
B002 - 基于嵌入式的老人定位追踪监测仪
Xingtu has been short of disruptive products?Will this M38T from the Qingdao factory be a breakthrough?
XAML WPF项目groupBox控件
TCP百万并发服务器优化调参
QLineEdit学习与使用