完整版 电路图和程序代码 下载地址
https://pan.baidu.com/s/1CV5uzQKQc2wI8w91tN93bg?pwd=3456
部分代码展示
*****************************************************************************
* 智能家居控制系统程序
* 单片机采用AT89S52,晶振频率为:12.00MHz。
/******************************************************************************/
#include <AT89X55.H>
bit r_flag;
enum eepromtype {M2401,M2402,M2404,M2408,M2416,M2432,M2464,M24128,M24256};
extern bit RW24XX(unsigned char *DataBuff,unsigned char ByteQuantity,unsigned int Address,
unsigned char ControlByte,enum eepromtype EepromType);
sbit key = P2^0;
bit key_flag;
sbit dog = P0^7;
sbit LED = P0^0;
sbit TELA = P3^6;
sbit TEL = P3^7;
sbit RING = P3^2;
sbit switching =P0^4;
unsigned char mode;
bit passwordflag;
unsigned char password[6];
unsigned char passwordtest[6];
void dlms(unsigned int x);
void reset(void);
void open(void);
//**************************************************************** //
// INT1中断服务程序 //
//**************************************************************** //
unsigned char ring_fluctuation;
unsigned char ring_count;
bit ring_flag;
void service_int0() interrupt 0 using 1
{
if(ring_fluctuation<10)
{
ring_fluctuation++;
}
}
//**************************************************************** //
// t1 定时中断 //
//**************************************************************** //
unsigned char ring_dlsm;
unsigned char ring_time;
unsigned int ring_reset_time;
unsigned char dlms_time;
void timer1 (void) interrupt 3 using 0
{
TH1=0x3c;
TL1=0xb0;
dlms_time++;
if(ring_fluctuation>5)
{
EX0=0;//INT1_OFF;
ring_dlsm++;
if(ring_dlsm==20)//等待一秒
{
ring_dlsm=0;
EX0=1;//INT1_ON;
ring_fluctuation=0;
ring_count++;//震铃次数
if(ring_flag)//有效振铃
{
if(ring_count==6)
{
ring_count=7;
mode=1;
}
}
else//无效振铃
{
if(ring_count>2)
{
ring_reset_time=800;
}
}
}
}
if((ring_count==2)|(ring_count==1))
{
ring_time++;
if(ring_time==200)
{
ring_flag=1;
}
}
if((ring_count>0)&(ring_count<6))
{
LED=INT0;
}
else if(passwordflag)
{
LED=~LED;
}
if(ring_count>0)
{
ring_reset_time++;
if(ring_reset_time==1100)//55s
{
reset();
LED=0;
dlms(100);
LED=1;
dlms(100);
LED=0;
dlms(100);
LED=1;
dlms(100);
LED=0;
dlms(100);
LED=1;
dlms(100);
LED=0;
dlms(100);
LED=1;
dlms(100);
LED=0;
dlms(100);
LED=1;
dlms(100);
LED=0;
dlms(100);
LED=switching;
}
}
}
//**************************************************************** //
// INT1中断服务程序 //
//**************************************************************** //
unsigned char DTMF;
void service_int1() interrupt 2 using 1
{
EX1=0;
DTMF=P1;
DTMF=DTMF>>4;
}
void main(void)
{
TMOD=0x11;
TH1=0x3c;
TL1=0xb0;
TR1=1;
ET1=1;
IT0=1;
EX0=1;
IT1=0;
EX1=1;