404 基于单片机家用电器远程控制系统设计(电路图 程序代码 )

 完整版 电路图和程序代码 下载地址

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;
  
  

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值