目录
- 基于51单片机的智能照明系统
- 一、原理图
- 二、部分代码
- 三、视频演示
基于51单片机的智能照明系统
功能:
1.通过LCD屏幕显示实时时间、光强和物体等
2.通过DS1302获取实时时间
3.通过按键调整灯的开关时间和手自动设置手动模式下手动开灯
4.蜂鸣器报警功能
5.上位机串口助手信息显示
一、原理图
二、部分代码
#include <reg52.h>
#include "lcd.h"
#include "adc.h"
#include "ds1302.h"
#include "hardware.h"
unsigned char add1 = 0;//ADC0832 采集两路AD add1是第一路 add2是第二路 范围是0-255
unsigned char add2 = 0;
unsigned char LED1_Open_Flag = 0;
unsigned char LED2_Open_Flag = 0;
unsigned char buffer3[24];
extern unsigned char Auto;
extern unsigned char shi;
extern unsigned char fen;
extern unsigned char add11;
extern unsigned char add22;
extern unsigned char LED1_Hand_Flag;
extern unsigned char LED2_Hand_Flag;
extern unsigned char LED1_Open_Shi;
extern unsigned char LED1_Open_Fen;
extern unsigned char LED1_Close_Shi;
extern unsigned char LED1_Close_Fen;
extern unsigned char LED2_Open_Shi;
extern unsigned char LED2_Open_Fen;
extern unsigned char LED2_Close_Shi;
extern unsigned char LED2_Close_Fen;
#define shi shi
#define fen fen
#define strDateBeginH1 LED1_Open_Shi
#define strDateBeginM1 LED1_Open_Fen
#define strDateEndH1 LED1_Close_Shi
#define strDateEndM1 LED1_Close_Fen
#define strDateBeginH2 LED2_Open_Shi
#define strDateBeginM2 LED2_Open_Fen
#define strDateEndH2 LED2_Close_Shi
#define strDateEndM2 LED2_Close_Fen
void LED_Model();
void main()
{
LcdInit();//LCD初始化
BEEP_OFF();
Uart_Init();
DS1302_Init();
DS1302_WriteByte(0x80,0x55);//0X55转化为BCD就是55
while(1)
{
Scan();
LcdShow();//LCD显示
Get_Tim();
Control();
LED_Model();
add1 = Adc0832(0);//光照获取 0-99
add2 = Adc0832(1);//物理检测
sprintf(buffer3, "L:%bu%% R:%bu%% %02bd-%02bd\r\n", add11, add22, shi, fen);
Send_String(buffer3);
}
}
三、视频演示
哔哩哔哩视频演示链接跳转,请直接点击!