|
问题还很多,大家可以继续完善:
个人为电子竞赛所做的《智能家居系统Proteus仿真设计》,现分享给大家,共同学习学习!
整个设计由Proteus仿真完成。智能家居系统有以下几个模块组成:
(1)中央处理器模块
(2)窗帘控制系统
(3)温度监控系统
(4)门禁密码系统
(5)居室灯光控制系统
(6)居室照明系统
(7)烟雾火灾报警系统
(8)室内中央显示系统
(9)按键设置系统
(10)门禁开关系统
(11)网络通讯系统
原理图为:
程序部分:
部分代码如下:
#include "DELAY.H"
#include "LATCH.H"
#include "DISPLAY.H"
#include "LCD1602.H"
#include "KEYSCAN.H"
#include "24C02.H"
#include "PCF8591.H"
#include "DS18B20.H"
#include "TIMER.H"
#define LedBright 0x00 //明亮
#define LedNormal 0x64 //一般
#define LedSleep 0xc8 //睡眠
#define ledClose 0xff //关闭
uchar KeyNum;
uchar LED_flag;
uchar LED_DIS_1;
uint LightRes;
uchar code LED_Light_Mode[]="Choose ledlight mode";
uchar code LEDNum[] = "1 2 3";
uchar code LED_Control_Mode[]="Choose ledcontrol mode";
uchar code LED_Control_Follow[]="1:Hand 2:Auto";
enum {Hand,Auto} Control_Follow = Hand;
uchar code DisProgram[]="Mode Status";
uchar code LED_Dis_One[]="LED LedBright";
uchar code LED_Dis_Two[]="LED LedNormal";
uchar code LED_Dis_Three[]="LED LedSleep";
uchar Led_i = 0;
uchar Led_j = 0;
uchar LedOutputValue;
uchar Timer0Num;
void main()
{
Init_TIME(0,0);
ChooseChannel(0x01);
Init_LCD();
while(1)
{
KeyNum = KeyScan();
if(KeyNum != 0xff)
{
if(KeyNum == 4) {LED_flag = 1; Led_i++; LedOutputValue = LedNormal;}
if(Led_i == 2) {LED_flag = 0; Led_i = 0; Led_j = 0; LED_DIS_1 = 0;}
if(LED_flag && KeyNum == 1 ) {Led_j++; if(Led_j == 1)LedOutputValue = LedBright; LED_DIS_1 = 1;}
if(LED_flag && KeyNum == 2 ) {Led_j++; if(Led_j == 1)LedOutputValue = LedNormal; LED_DIS_1 = 1;}
if(LED_flag && KeyNum == 3 ) {Led_j++; if(Led_j == 1)LedOutputValue = LedSleep; LED_DIS_1 = 1;}
}
if(LED_flag && (LED_DIS_1 == 0))
{
LCDPosition(1,LED_Light_Mode);
LCDPosition(2,LEDNum);
}
if(LED_DIS_1 && (Led_j==1))
{
LCDPosition(1,LED_Control_Mode);
LCDPosition(2,LED_Control_Follow);
}
if((KeyNum == 1)&& (Led_j==2)) Control_Follow = Hand;
if((KeyNum == 2)&& (Led_j==2)) Control_Follow = Auto;
// if(Control_Follow == Hand) DA_Sent(LedOutputValue);
if(Control_Follow == Auto)
{
TR0 = 1;
if(LightRes > 180) LedOutputValue = LedSleep;
else if(LightRes > 100 && LightRes < 180 ) LedOutputValue = LedNormal;
else LedOutputValue = LedBright;
}
if(Led_j==2)
{
LCDPosition(1,DisProgram);
switch(LedOutputValue)
{
case LedBright: LCDPosition(2,LED_Dis_One); break;
case LedNormal: LCDPosition(2,LED_Dis_Two); break;
case LedSleep: LCDPosition(2,LED_Dis_Three); break;
}
}
DA_Sent(LedOutputValue);
// LCDPosition(1,LED_Light_Mode);
}
}
void Timer0() interrupt 1
{
TH0 = (65536-50000)/256;
TL0 = (65536 - 50000)%256;
Timer0Num++;
if(Timer0Num == 20)
{
Timer0Num = 0;
LightRes = AD_Receive();
}
}
仿真文件和程序见附件:
不能运行,仿真没有反应,求大神指导:
仿真程序有错误,求大神帮助.7z
(63.72 KB, 下载次数: 285)
|
|