智能家居控制系统C程序
[日期:2010-03-03 ] [来源:本站编辑 作者:admin] [字体:大 中 小] (投递新闻)
#include <>
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;
智能家居控制系统C程序



