欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 4076|回復: 3
打印 上一主題 下一主題
收起左側

基于51單片機的教室節電系統設計

[復制鏈接]
跳轉到指定樓層
樓主
這是我做的一個小的設計,使用了LCD1602顯示,DS1302時鐘芯片,51最小系統等。


所有資料打包下載:
4.教室節電.rar (209.59 KB, 下載次數: 45)

下面是部分源碼預覽:
  1. #include "includes.h"
  2. #include "structions.h"

  3. sbit relay = P1^7;  //繼電器接口 0:吸合,1:斷開

  4. void Read_Time(void); //讀取時間
  5. void LCD_DIS_CurrenTime();  //液晶顯示當前時間
  6. void LCD_Const0(); //在液晶上顯示固定東西
  7. void LCD_Const1();
  8. void LCD_Const2(); //在液晶上顯示固定東西


  9. void Key_Handle_Work(void); //工作模式中,按鍵處理
  10. void Key_Handle_Cfg(void);  //設置模式中,按鍵處理
  11. void Ds1302_Set_CurrentTime(void);
  12. uchar keyValue = 0;   //鍵值
  13. uchar relayMode = 0;  //默認為自動模式
  14. uchar workMode = 1;   //0:設置,1:工作
  15. uchar disMode = 0;    //顯示模式:0顯示當前時間  1顯示第一組開關燈時間  2顯示第二組開關燈時間

  16. uchar lcdPoint1 = 0;   //lcd顯示第一頁光標位置
  17. uchar lcdPoint2 = 0;   //lcd顯示第二頁光標位置
  18. uchar lcdPoint3 = 0;   //lcd顯示第三頁光標位置

  19. uchar workENA1 = 0;    //第一組工作使能
  20. uchar workENA2 = 0;    //第二組工作使能
  21. void main()
  22. {   

  23. //     Uart_Init(9600);//串口初始化
  24.            Ds1302_Init();  
  25.            LCD_Init();
  26.            Timer1_Init();
  27.            relay = 1;
  28.            Read_Time();               //讀取當前時間
  29.            LCD_Const0();
  30.            Read_Time();               //讀取當前時間
  31.            LCD_DIS_CurrenTime();
  32.         while(1)
  33.          {
  34.                              
  35.                   keyValue = Read_KeyNum();  //讀鍵值
  36.                  
  37.                 if(workMode == 1)
  38.                 {

  39.                                                                 Key_Handle_Work();
  40.                if(relayMode == 0)   //自動模式
  41.                                                          {
  42.                                                                         if(CurrentTime.Week == 1)
  43.                                                                         {
  44.                                                                                 workENA1 = WeekENA1.Mon,workENA2 = WeekENA2.Mon;
  45.                                                                         }
  46.                                                                         if(CurrentTime.Week == 2)
  47.                                                                         {
  48.                                                                                 workENA1 = WeekENA1.Tue,workENA2 = WeekENA2.Tue;
  49.                                                                         }
  50.                                                                         if(CurrentTime.Week == 3)
  51.                                                                         {
  52.                                                                                 workENA1 = WeekENA1.Wed,workENA2 = WeekENA2.Wed;
  53.                                                                         }
  54.                                                                         if(CurrentTime.Week == 4)
  55.                                                                         {
  56.                                                                                 workENA1 = WeekENA1.Thu,workENA2 = WeekENA2.Thu;
  57.                                                                         }
  58.                                                                         if(CurrentTime.Week == 5)
  59.                                                                         {
  60.                                                                                 workENA1 = WeekENA1.Fri,workENA2 = WeekENA2.Fri;
  61.                                                                         }
  62.                                                                         if(CurrentTime.Week == 6)
  63.                                                                         {
  64.                                                                                 workENA1 = WeekENA1.Sat,workENA2 = WeekENA2.Sat;
  65.                                                                         }
  66.                                                                         if(CurrentTime.Week == 7)
  67.                                                                         {
  68.                                                                                 workENA1 = WeekENA1.Sun,workENA2 = WeekENA2.Sun;
  69.                                                                         }
  70.                                                                        
  71.                                                                         if(workENA1 == 1||workENA2 == 1)
  72.                                                                         {
  73.                                                                                         if(CurrentTime.Hour==OpenTime1.Hour&&CurrentTime.Minute==OpenTime1.Minute&&CurrentTime.Second==0)
  74.                                                                                         {
  75.                                                                                                 relay = 0;
  76.                                                                                         }
  77.                                                                                         if(CurrentTime.Hour==CloseTime1.Hour&&CurrentTime.Minute==CloseTime1.Minute&&CurrentTime.Second==0)
  78.                                                                                         {
  79.                                                                                                 relay = 1;
  80.                                                                                         }
  81.                                                                                         //上面是第一組
  82.                                                                                         //下面是第二組
  83.                                                                                         if(CurrentTime.Hour==OpenTime2.Hour&&CurrentTime.Minute==OpenTime2.Minute&&CurrentTime.Second==0)
  84.                                                                                         {
  85.                                                                                                 relay = 0;
  86.                                                                                         }
  87.                                                                                         if(CurrentTime.Hour==CloseTime2.Hour&&CurrentTime.Minute==CloseTime2.Minute&&CurrentTime.Second==0)
  88.                                                                                         {
  89.                                                                                                 relay = 1;
  90.                                                                                         }
  91.                                                                         }
  92.                                                          }
  93.                                                          
  94.                                                                  LCD_DIS_CurrenTime();      //顯示當前時間
  95.                                                          if(keyValue == 5)
  96.                                                          {
  97.                                                                          LCD_Write_Com(0x80+1);
  98.                                                                         LCD_Write_Com(0x0f); //光標閃爍
  99.                                                                   lcdPoint1 = 1;
  100.                                                                 }
  101.                  }
  102.                                                          
  103.                 if(workMode == 0)
  104.                 {
  105.                                                Key_Handle_Cfg();
  106.                                                                  relay =1; //關燈(繼電器)
  107.                        
  108.                 }
  109.                         
  110.          
  111.          }       
  112. }

  113. void Timer1_Isr(void) interrupt 3
  114. {
  115.         uint t;
  116.         TR1=0;
  117.         TH1=(65536-50000) / 256;          
  118.   TL1=(65536-50000) %256;
  119.         t++;
  120.         if(t == 20)
  121.         {
  122.                 t = 0;
  123.                 if(workMode == 1) //處于工作模式的時候才需要讀取現在時間
  124.                 {
  125.                   Read_Time();               //讀取當前時間
  126.                 }

  127.         }
  128.        
  129.   TR1=1;
  130. }


  131. void Key_Handle_Work(void)
  132. {
  133.          if(relayMode == 0)     //如果在自動模式下按下按鍵 ,就是手動開關燈
  134.          {
  135.                  if(keyValue == 1)
  136.                  {
  137.                          if(workENA1 == 1||workENA2 == 1)
  138.                          {
  139.                          relay = ~relay;
  140.                          }
  141.                  }
  142.          }
  143.         if(keyValue == 2)
  144.         {
  145.                         relayMode++;
  146.                 if(relayMode == 0)
  147.                 {
  148.             LCD_Write_Char(14,1,'A');
  149.             LCD_Write_Char(15,1,'u');                       
  150.                 }
  151.                 if(relayMode == 1)
  152.                 {
  153.             LCD_Write_Char(14,1,'O');
  154.             LCD_Write_Char(15,1,'p');       
  155.                          relay = 0;
  156.                 }
  157.                 if(relayMode == 2)
  158.                 {
  159.             LCD_Write_Char(14,1,'C');
  160.             LCD_Write_Char(15,1,'l');       
  161.                         relay = 1;                       
  162.                 }

  163.                 if(relayMode>=3)
  164.                 {
  165.                         relayMode = 0;
  166.                         LCD_Write_Char(14,1,'A');
  167.             LCD_Write_Char(15,1,'u');       
  168.                 }
  169.         }
  170.        
  171.         if(keyValue == 5)  //按下設置按鍵
  172.         {
  173.                 workMode = 0;
  174.                 LCD_Write_Char(14,1,'C');
  175.           LCD_Write_Char(15,1,'F');
  176.      disMode = 0;
  177.                  lcdPoint1 = 0;   
  178.      lcdPoint2 = 0;   
  179.      lcdPoint3 = 0;   
  180.                    
  181.         }
  182.        
  183.        
  184. }

  185. void Key_Handle_Cfg(void)
  186. {
  187.     uchar dayMax = 0;
  188.                 if(keyValue == 1)  //按下移位
  189.          {
  190.                  if(disMode == 0)     //顯示當前時間
  191.                  {
  192.                                                         lcdPoint1++;
  193.                                                         if(lcdPoint1 == 1)         //
  194.                                                  {
  195.                                                          LCD_Write_Com(0x80+1);
  196.                                                  }
  197.                                                         if(lcdPoint1 == 2)
  198.                                                  {
  199.                                                          LCD_Write_Com(0x80+4);
  200.                                                  }
  201.                                                         if(lcdPoint1 == 3)
  202.                                                  {
  203.                                                          LCD_Write_Com(0x80+7);
  204.                                                  }
  205.                                                         if(lcdPoint1 == 4)
  206.                                                  {
  207.                                                          LCD_Write_Com(0xc0+1);
  208.                                                  }
  209.                                                         if(lcdPoint1 == 5)
  210.                                                  {
  211.                                                          LCD_Write_Com(0xc0+4);
  212.                                                  }
  213.                                                         if(lcdPoint1 == 6)
  214.                                                  {
  215.                                                          LCD_Write_Com(0xc0+7);
  216.                                                  }
  217.                                                  if(lcdPoint1>6)
  218.                                                  {
  219.                                                          lcdPoint1 = 1;
  220.                                                          LCD_Write_Com(0x80+1);
  221.                                                  }
  222.                 }                 
  223.                 if(disMode == 1)     //顯示開關燈時間1
  224.                  {
  225.                                                         lcdPoint2++;
  226.                                                         if(lcdPoint2 == 1)         //
  227.                                                  {
  228.                                                          LCD_Write_Com(0x80+6);
  229.                                                  }
  230.                                                         if(lcdPoint2 == 2)
  231.                                                  {
  232.                                                          LCD_Write_Com(0x80+7);
  233.                                                  }
  234.                                                         if(lcdPoint2 == 3)
  235.                                                  {
  236.                                                          LCD_Write_Com(0x80+8);
  237.                                                  }
  238.                                                         if(lcdPoint2 == 4)
  239.                                                  {
  240.                                                          LCD_Write_Com(0x80+9);
  241.                                                  }
  242.                                                         if(lcdPoint2 == 5)
  243.                                                  {
  244.                                                          LCD_Write_Com(0x80+10);
  245.                                                  }
  246.                                                         if(lcdPoint2 == 6)
  247.                                                  {
  248.                                                          LCD_Write_Com(0x80+11);
  249.                                                  }
  250.                                                          if(lcdPoint2 == 7)
  251.                                                  {
  252.                                                          LCD_Write_Com(0x80+12);
  253.                                                  }
  254.                                                          if(lcdPoint2 == 8)
  255.                                                  {
  256.                                                          LCD_Write_Com(0xc0+3);
  257.                                                  }
  258.                                                          if(lcdPoint2 == 9)
  259.                                                  {
  260.                                                          LCD_Write_Com(0xc0+6);
  261.                                                  }
  262.                                                          if(lcdPoint2 == 10)
  263.                                                  {
  264.                                                          LCD_Write_Com(0xc0+12);
  265.                                                  }
  266.                                                          if(lcdPoint2 == 11)
  267.                                                  {
  268.                                                          LCD_Write_Com(0xc0+15);
  269.                                                  }                                                 
  270.                                                  
  271.                                                  if(lcdPoint2>11)
  272.                                                  {
  273.                                                          lcdPoint2 = 1;
  274.                                                          LCD_Write_Com(0x80+6);
  275.                                                  }
  276.                 }
  277.                 if(disMode == 2)     //顯示開關燈時間2
  278.                 {
  279.                                                         lcdPoint3++;
  280.                                                         if(lcdPoint3 == 1)         //
  281.                                                  {
  282.                                                          LCD_Write_Com(0x80+6);
  283.                                                  }
  284.                                                         if(lcdPoint3 == 2)
  285.                                                  {
  286.                                                          LCD_Write_Com(0x80+7);
  287.                                                  }
  288.                                                         if(lcdPoint3 == 3)
  289.                                                  {
  290.                                                          LCD_Write_Com(0x80+8);
  291.                                                  }
  292.                                                         if(lcdPoint3 == 4)
  293.                                                  {
  294.                                                          LCD_Write_Com(0x80+9);
  295.                                                  }
  296.                                                         if(lcdPoint3 == 5)
  297.                                                  {
  298.                                                          LCD_Write_Com(0x80+10);
  299.                                                  }
  300.                                                         if(lcdPoint3 == 6)
  301.                                                  {
  302.                                                          LCD_Write_Com(0x80+11);
  303.                                                  }
  304.                                                          if(lcdPoint3 == 7)
  305.                                                  {
  306.                                                          LCD_Write_Com(0x80+12);
  307.                                                  }
  308.                                                          if(lcdPoint3 == 8)
  309.                                                  {
  310.                                                          LCD_Write_Com(0xc0+3);
  311.                                                  }
  312.                                                          if(lcdPoint3 == 9)
  313.                                                  {
  314.                                                          LCD_Write_Com(0xc0+6);
  315.                                                  }
  316.                                                          if(lcdPoint3 == 10)
  317.                                                  {
  318.                                                          LCD_Write_Com(0xc0+12);
  319.                                                  }
  320.                                                          if(lcdPoint3 == 11)
  321.                                                  {
  322.                                                          LCD_Write_Com(0xc0+15);
  323.                                                  }                                                 
  324.                                                  
  325.                                                  if(lcdPoint3>11)
  326.                                                  {
  327.                                                          lcdPoint3 = 1;
  328.                                                          LCD_Write_Com(0x80+6);
  329.                                                  }
  330.                 }                                
  331.                  
  332.          }
  333.                 if(keyValue == 2)  //按下加
  334.          {
  335.                  if(disMode == 0)                 //顯示當前時間
  336.                  {
  337.                                                  if(lcdPoint1 == 1)         //指向當前小時
  338.                                          {
  339.                                                  CurrentTime.Hour++;
  340.                                                  if(CurrentTime.Hour>23)
  341.                                                  {CurrentTime.Hour = 0;}
  342.                                                  
  343.                                                         LCD_Write_Char(0,0,CurrentTime.Hour/10+0x30);
  344.                                                         LCD_Write_Char(1,0,CurrentTime.Hour%10+0x30);       
  345.                                                         LCD_Write_Com(0x80+1);         
  346.                                                 }                                       
  347.                                                  
  348.                                                 if(lcdPoint1 == 2)          //指向當前分鐘
  349.                                          {
  350.                                                         CurrentTime.Minute++;
  351.                                                  if(CurrentTime.Minute>59)
  352.                                                  {CurrentTime.Minute = 0;}
  353.                                                         LCD_Write_Char(3,0,CurrentTime.Minute/10+0x30);
  354.                                                         LCD_Write_Char(4,0,CurrentTime.Minute%10+0x30);
  355.                                                         LCD_Write_Com(0x80+4);
  356.                                          }
  357.                                                  
  358.                                                 if(lcdPoint1 == 3)          //指向當前秒
  359.                                          {
  360.                                                         CurrentTime.Second++;
  361.                                                  if(CurrentTime.Second>59)
  362.                                                  {CurrentTime.Second = 0;}
  363.                                                         LCD_Write_Char(6,0,CurrentTime.Second/10+0x30);
  364.                                                         LCD_Write_Char(7,0,CurrentTime.Second%10+0x30);                 
  365.                                                         LCD_Write_Com(0x80+7);
  366.                                          }
  367.                                          
  368.                                                 if(lcdPoint1 == 4)        //指向當前年
  369.                                          {
  370.                                                         CurrentTime.Year++;
  371.                                                  if(CurrentTime.Year>30)
  372.                                                  {CurrentTime.Year = 16;}
  373.                                                        
  374.                                                  LCD_Write_Char(0,1,CurrentTime.Year/10+0x30);
  375.                                                  LCD_Write_Char(1,1,CurrentTime.Year%10+0x30);
  376.                                                  LCD_Write_Com(0xc0+1);                 
  377.                                          }
  378.                                                 if(lcdPoint1 == 5)        //指向當前月
  379.                                          {
  380.                                                         CurrentTime.Month++;
  381.                                                  if(CurrentTime.Month>12)
  382.                                                  {CurrentTime.Month = 1;}
  383.                                                  LCD_Write_Char(3,1,CurrentTime.Month/10+0x30);
  384.                                                  LCD_Write_Char(4,1,CurrentTime.Month%10+0x30);                         
  385.                                                  LCD_Write_Com(0xc0+4);
  386.                                                  
  387.                                          }
  388.                                          if(lcdPoint1==6)            //指向當前日
  389.                                          {
  390.                                                  if(CurrentTime.Month == 1||CurrentTime.Month == 3||CurrentTime.Month == 5||CurrentTime.Month == 7||CurrentTime.Month == 8||CurrentTime.Month == 10||CurrentTime.Month == 12)
  391.                                                  {dayMax = 31;}
  392.                                                  if(CurrentTime.Month == 4||CurrentTime.Month == 6||CurrentTime.Month == 9||CurrentTime.Month == 11)
  393.                                                  {dayMax = 30;}
  394.                                                  if(CurrentTime.Month == 2&&((CurrentTime.Year%4)!=0))
  395.                                                  {dayMax = 28;}
  396.                                                         if(CurrentTime.Month == 2&&((CurrentTime.Year%4)==0))
  397.                                                  {dayMax = 29;}
  398.                                                         CurrentTime.Day++;
  399.                                                  if(CurrentTime.Day>dayMax)
  400.                                                  {CurrentTime.Day = 1;}
  401.                                                  LCD_Write_Char(6,1,CurrentTime.Day/10+0x30);
  402.                                                  LCD_Write_Char(7,1,CurrentTime.Day%10+0x30);                         
  403.                                                  LCD_Write_Com(0xc0+7);
  404.                                          }
  405.                 }
  406.                  if(disMode == 1)                 //顯示開關燈時間1
  407.                  {
  408.                                                 if(lcdPoint2 == 1)         //指向星期1使能位
  409.                                          {
  410.                                                  WeekENA1.Mon = !WeekENA1.Mon;
  411.                                                  LCD_Write_Char(6,0,WeekENA1.Mon+0x30);
  412.                                                  LCD_Write_Com(0x80+6);         
  413.                                                 }
  414.                                                 if(lcdPoint2 == 2)         //指向星期2使能位
  415.                                          {
  416.                                                  WeekENA1.Tue = !WeekENA1.Tue;
  417.                                                  LCD_Write_Char(7,0,WeekENA1.Tue+0x30);
  418.                                                  LCD_Write_Com(0x80+7);         
  419.                                                 }
  420.                                                 if(lcdPoint2 == 3)         //指向星期3使能位
  421.                                          {
  422.                                                  WeekENA1.Wed = !WeekENA1.Wed;
  423.                                                  LCD_Write_Char(8,0,WeekENA1.Wed+0x30);
  424.                                                  LCD_Write_Com(0x80+8);         
  425.                                                 }
  426.                                                 if(lcdPoint2 == 4)         //指向星期4使能位
  427.                                          {
  428.                                                  WeekENA1.Thu = !WeekENA1.Thu;
  429.                                                  LCD_Write_Char(9,0,WeekENA1.Thu+0x30);
  430.                                                  LCD_Write_Com(0x80+9);         
  431.                                                 }
  432.                                                 if(lcdPoint2 == 5)         //指向星期5使能位
  433.                                          {
  434.                                                  WeekENA1.Fri = !WeekENA1.Fri;
  435.                                                  LCD_Write_Char(10,0,WeekENA1.Fri+0x30);
  436.                                                  LCD_Write_Com(0x80+10);         
  437.                                                 }
  438.                                                 if(lcdPoint2 == 6)         //指向星期6使能位
  439.                                          {
  440.                                                  WeekENA1.Sat = !WeekENA1.Sat;
  441.                                                  LCD_Write_Char(11,0,WeekENA1.Sat+0x30);
  442.                                                  LCD_Write_Com(0x80+11);         
  443.                                                 }
  444.                                                 if(lcdPoint2 == 7)         //指向星期7使能位
  445.                                           {
  446.                                                  WeekENA1.Sun = !WeekENA1.Sun;
  447.                                                  LCD_Write_Char(12,0,WeekENA1.Sun+0x30);
  448.                                                  LCD_Write_Com(0x80+12);         
  449.                                                 }
  450.                                                 if(lcdPoint2 == 8)
  451.                                                  {
  452.                                                          OpenTime1.Hour++;
  453.                                                          if(OpenTime1.Hour>23)
  454.                                                          {
  455.                                                                  OpenTime1.Hour = 0;
  456.                                                          }                                         
  457.                                                          LCD_Write_Char(2,1,OpenTime1.Hour/10+0x30);       
  458.                                                          LCD_Write_Char(3,1,OpenTime1.Hour%10+0x30);                                                         
  459.                                                          LCD_Write_Com(0xc0+3);
  460.                                                  }
  461.                                           if(lcdPoint2 == 9)
  462.                                                 {
  463.                                                          OpenTime1.Minute++;
  464.                                                          if(OpenTime1.Minute>59)
  465.                                                          {
  466.                                                                  OpenTime1.Minute = 0;
  467.                                                          }                                         
  468.                                                          LCD_Write_Char(5,1,OpenTime1.Minute/10+0x30);       
  469.                                                          LCD_Write_Char(6,1,OpenTime1.Minute%10+0x30);                                                         
  470.                                              LCD_Write_Com(0xc0+6);
  471.                                                 }
  472.                                                 if(lcdPoint2 == 10)
  473.                                           {
  474.                                                          CloseTime1.Hour++;
  475.                                                          if(CloseTime1.Hour>23)
  476.                                                          {
  477.                                                                  CloseTime1.Hour = 0;
  478.                                                          }                                         
  479.                                                          LCD_Write_Char(11,1,CloseTime1.Hour/10+0x30);       
  480.                                                          LCD_Write_Char(12,1,CloseTime1.Hour%10+0x30);                                                         
  481.                                                    LCD_Write_Com(0xc0+12);
  482.                                           }
  483.                                                 if(lcdPoint2 == 11)
  484.                                           {
  485.                                                          CloseTime1.Minute++;
  486.                                                          if(CloseTime1.Minute>59)
  487.                                                          {
  488.                                                                  CloseTime1.Minute = 0;
  489.                                                          }                                         
  490.                                                          LCD_Write_Char(14,1,CloseTime1.Minute/10+0x30);       
  491.                                                          LCD_Write_Char(15,1,CloseTime1.Minute%10+0x30);                                                                                                                 
  492.                                                    LCD_Write_Com(0xc0+15);
  493.                                           }                                                                                                        
  494.                                                            
  495.                  }
  496.                         if(disMode == 2)                 //顯示開關燈時間2
  497.                  {
  498.                                                 if(lcdPoint3 == 1)         //指向星期1使能位
  499.                                          {
  500.                                                  WeekENA2.Mon = !WeekENA2.Mon;
  501.                                                  LCD_Write_Char(6,0,WeekENA2.Mon+0x30);
  502.                                                  LCD_Write_Com(0x80+6);         
  503.                                                 }
  504.                                                 if(lcdPoint3 == 2)         //指向星期2使能位
  505.                                          {
  506.                                                  WeekENA2.Tue = !WeekENA2.Tue;
  507.                                                  LCD_Write_Char(7,0,WeekENA2.Tue+0x30);
  508.                                                  LCD_Write_Com(0x80+7);         
  509.                                                 }
  510.                                                 if(lcdPoint3 == 3)         //指向星期3使能位
  511.                                          {
  512.                                                  WeekENA2.Wed = !WeekENA2.Wed;
  513.                                                  LCD_Write_Char(8,0,WeekENA2.Wed+0x30);
  514.                                                  LCD_Write_Com(0x80+8);         
  515.                                                 }
  516.                                                 if(lcdPoint3 == 4)         //指向星期4使能位
  517.                                          {
  518.                                                  WeekENA2.Thu = !WeekENA2.Thu;
  519.                                                  LCD_Write_Char(9,0,WeekENA2.Thu+0x30);
  520.                                                  LCD_Write_Com(0x80+9);         
  521.                                                 }
  522.                                                 if(lcdPoint3 == 5)         //指向星期5使能位
  523.                                          {
  524.                                                  WeekENA2.Fri = !WeekENA2.Fri;
  525.                                                  LCD_Write_Char(10,0,WeekENA2.Fri+0x30);
  526.                                                  LCD_Write_Com(0x80+10);         
  527.                                                 }
  528.                                                 if(lcdPoint3 == 6)         //指向星期6使能位
  529.                                          {
  530.                                                  WeekENA2.Sat = !WeekENA2.Sat;
  531.                                                  LCD_Write_Char(11,0,WeekENA2.Sat+0x30);
  532.                                                  LCD_Write_Com(0x80+11);         
  533.                                                 }
  534.                                                 if(lcdPoint3 == 7)         //指向星期7使能位
  535.                                          {
  536.                                                  WeekENA2.Sun = !WeekENA2.Sun;
  537.                                                  LCD_Write_Char(12,0,WeekENA2.Sun+0x30);
  538.                                                  LCD_Write_Com(0x80+12);         
  539.                                                 }
  540.                                                
  541.                                           if(lcdPoint3 == 8)
  542.                                                  {
  543.                                                          OpenTime2.Hour++;
  544.                                                          if(OpenTime2.Hour>23)
  545.                                                          {
  546.                                                                  OpenTime2.Hour = 0;
  547.                                                          }                                         
  548.                                                          LCD_Write_Char(2,1,OpenTime2.Hour/10+0x30);       
  549.                                                          LCD_Write_Char(3,1,OpenTime2.Hour%10+0x30);                                                         
  550.                                                          LCD_Write_Com(0xc0+3);
  551.                                                  }
  552.                                           if(lcdPoint3 == 9)
  553.                                                 {
  554.                                                          OpenTime2.Minute++;
  555.                                                          if(OpenTime2.Minute>59)
  556.                                                          {
  557.                                                                  OpenTime2.Minute = 0;
  558.                                                          }                                         
  559.                                                          LCD_Write_Char(5,1,OpenTime2.Minute/10+0x30);       
  560.                                                          LCD_Write_Char(6,1,OpenTime2.Minute%10+0x30);                                                         
  561.                                              LCD_Write_Com(0xc0+6);
  562.                                                 }
  563.                                                 if(lcdPoint3 == 10)
  564.                                           {
  565.                                                          CloseTime2.Hour++;
  566.                                                          if(CloseTime2.Hour>23)
  567.                                                          {
  568.                                                                  CloseTime2.Hour = 0;
  569.                                                          }                                         
  570.                                                          LCD_Write_Char(11,1,CloseTime2.Hour/10+0x30);       
  571.                                                          LCD_Write_Char(12,1,CloseTime2.Hour%10+0x30);                                                         
  572.                                                    LCD_Write_Com(0xc0+12);
  573.                                           }
  574.                                                 if(lcdPoint3 == 11)
  575.                                           {
  576.                                                          CloseTime2.Minute++;
  577.                                                          if(CloseTime2.Minute>59)
  578.                                                          {
  579.                                                                  CloseTime2.Minute = 0;
  580.                                                          }                                         
  581.                                                          LCD_Write_Char(14,1,CloseTime2.Minute/10+0x30);       
  582.                                                          LCD_Write_Char(15,1,CloseTime2.Minute%10+0x30);                                                                                                                 
  583.                                                    LCD_Write_Com(0xc0+15);
  584.                                           }                                                        
  585.                 }
  586.          }
  587.          
  588.                 if(keyValue == 3)  //按下減
  589.         {
  590.                 if(disMode == 0)                   //顯示當前時間
  591.                 {
  592.                                                 if(lcdPoint1 == 1)         //指向當前小時
  593.                                          {
  594.                                                  CurrentTime.Hour--;
  595.                                                  if(CurrentTime.Hour<0)
  596.                                                  {CurrentTime.Hour = 23;}
  597.                                                  
  598.                                                         LCD_Write_Char(0,0,CurrentTime.Hour/10+0x30);
  599.                                                         LCD_Write_Char(1,0,CurrentTime.Hour%10+0x30);       
  600.                                                         LCD_Write_Com(0x80+1);         
  601.                                                 }
  602.                                                        
  603.                                                  
  604.                                                 if(lcdPoint1 == 2)          //指向當前分鐘
  605.                                          {
  606.                                                         CurrentTime.Minute--;
  607.                                                  if(CurrentTime.Minute<0)
  608.                                                  {CurrentTime.Minute = 59;}
  609.                                                         LCD_Write_Char(3,0,CurrentTime.Minute/10+0x30);
  610.                                                         LCD_Write_Char(4,0,CurrentTime.Minute%10+0x30);
  611.                                                         LCD_Write_Com(0x80+4);
  612.                                          }
  613.                                                  
  614.                                                 if(lcdPoint1 == 3)          //指向當前秒
  615.                                          {
  616.                                                         CurrentTime.Second--;
  617.                                                  if(CurrentTime.Second<0)
  618.                                                  {CurrentTime.Second = 59;}
  619.                                                         LCD_Write_Char(6,0,CurrentTime.Second/10+0x30);
  620.                                                         LCD_Write_Char(7,0,CurrentTime.Second%10+0x30);                 
  621.                                                         LCD_Write_Com(0x80+7);
  622.                                          }
  623.                                          
  624.                                                 if(lcdPoint1 == 4)        //指向當前年
  625.                                          {
  626.                                                         CurrentTime.Year--;
  627.                                                  if(CurrentTime.Year<16)
  628.                                                  {CurrentTime.Year = 30;}
  629.                                                        
  630.                                                  LCD_Write_Char(0,1,CurrentTime.Year/10+0x30);
  631.                                                  LCD_Write_Char(1,1,CurrentTime.Year%10+0x30);
  632.                                                  LCD_Write_Com(0xc0+1);                 
  633.                                          }
  634.                                                 if(lcdPoint1 == 5)        //指向當前月
  635.                                          {
  636.                                                         CurrentTime.Month--;
  637.                                                  if(CurrentTime.Month<1)
  638.                                                  {CurrentTime.Month = 12;}
  639.                                                  LCD_Write_Char(3,1,CurrentTime.Month/10+0x30);
  640.                                                  LCD_Write_Char(4,1,CurrentTime.Month%10+0x30);                         
  641.                                                  LCD_Write_Com(0xc0+4);
  642.                                                  
  643.                                          }
  644.                                          if(lcdPoint1==6)            //指向當前日
  645.                                          {
  646.                                                  if(CurrentTime.Month == 1||CurrentTime.Month == 3||CurrentTime.Month == 5||CurrentTime.Month == 7||CurrentTime.Month == 8||CurrentTime.Month == 10||CurrentTime.Month == 12)
  647.                                                  {dayMax = 31;}
  648.                                                  if(CurrentTime.Month == 4||CurrentTime.Month == 6||CurrentTime.Month == 9||CurrentTime.Month == 11)
  649.                                                  {dayMax = 30;}
  650.                                                  if(CurrentTime.Month == 2&&((CurrentTime.Year%4)!=0))
  651.                                                  {dayMax = 28;}
  652.                                                         if(CurrentTime.Month == 2&&((CurrentTime.Year%4)==0))
  653.                                                  {dayMax = 29;}
  654.                                                         CurrentTime.Day--;
  655.                                                  if(CurrentTime.Day<1)
  656.                                                  {CurrentTime.Day = dayMax;}
  657.                                                  LCD_Write_Char(6,1,CurrentTime.Day/10+0x30);
  658.                                                  LCD_Write_Char(7,1,CurrentTime.Day%10+0x30);                         
  659.                                                  LCD_Write_Com(0xc0+7);
  660.                                          }
  661.                 }
  662.                 if(disMode == 1)                 //顯示開關燈時間1
  663.                  {
  664.                                                 if(lcdPoint2 == 1)         //指向星期1使能位
  665.                                          {
  666.                                                  WeekENA1.Mon = !WeekENA1.Mon;
  667.                                                  LCD_Write_Char(6,0,WeekENA1.Mon+0x30);
  668.                                                  LCD_Write_Com(0x80+6);         
  669.                                                 }
  670.                                                 if(lcdPoint2 == 2)         //指向星期2使能位
  671.                                          {
  672.                                                  WeekENA1.Tue = !WeekENA1.Tue;
  673.                                                  LCD_Write_Char(7,0,WeekENA1.Tue+0x30);
  674.                                                  LCD_Write_Com(0x80+7);         
  675.                                                 }
  676.                                                 if(lcdPoint2 == 3)         //指向星期3使能位
  677.                                          {
  678.                                                  WeekENA1.Wed = !WeekENA1.Wed;
  679.                                                  LCD_Write_Char(8,0,WeekENA1.Wed+0x30);
  680.                                                  LCD_Write_Com(0x80+8);         
  681.                                                 }
  682.                                                 if(lcdPoint2 == 4)         //指向星期4使能位
  683.                                          {
  684.                                                  WeekENA1.Thu = !WeekENA1.Thu;
  685.                                                  LCD_Write_Char(9,0,WeekENA1.Thu+0x30);
  686.                                                  LCD_Write_Com(0x80+9);         
  687.                                                 }
  688.                                                 if(lcdPoint2 == 5)         //指向星期5使能位
  689.                                          {
  690.                                                  WeekENA1.Fri = !WeekENA1.Fri;
  691.                                                  LCD_Write_Char(10,0,WeekENA1.Fri+0x30);
  692.                                                  LCD_Write_Com(0x80+10);         
  693.                                                 }
  694.                                                 if(lcdPoint2 == 6)         //指向星期6使能位
  695.                                          {
  696.                                                  WeekENA1.Sat = !WeekENA1.Sat;
  697.                                                  LCD_Write_Char(11,0,WeekENA1.Sat+0x30);
  698.                                                  LCD_Write_Com(0x80+11);         
  699.                                                 }
  700.                                                 if(lcdPoint2 == 7)         //指向星期7使能位
  701.                                           {
  702.                                                  WeekENA1.Sun = !WeekENA1.Sun;
  703.                                                  LCD_Write_Char(12,0,WeekENA1.Sun+0x30);
  704.                                                  LCD_Write_Com(0x80+12);         
  705.                                                 }
  706.                                                 if(lcdPoint2 == 8)
  707.                                                  {
  708.                                                          OpenTime1.Hour--;
  709.                                                          if(OpenTime1.Hour<0)
  710.                                                          {
  711.                                                                  OpenTime1.Hour = 23;
  712.                                                          }                                         
  713.                                                          LCD_Write_Char(2,1,OpenTime1.Hour/10+0x30);       
  714.                                                          LCD_Write_Char(3,1,OpenTime1.Hour%10+0x30);                                                         
  715.                                                          LCD_Write_Com(0xc0+3);
  716.                                                  }
  717.                                           if(lcdPoint2 == 9)
  718.                                                 {
  719.                                                          OpenTime1.Minute--;
  720.                                                          if(OpenTime1.Minute<0)
  721.                                                          {
  722.                                                                  OpenTime1.Minute = 59;
  723.                                                          }                                         
  724.                                                          LCD_Write_Char(5,1,OpenTime1.Minute/10+0x30);       
  725.                                                          LCD_Write_Char(6,1,OpenTime1.Minute%10+0x30);                                                         
  726.                                              LCD_Write_Com(0xc0+6);
  727.                                                 }
  728.                                                 if(lcdPoint2 == 10)
  729.                                           {
  730.                                                          CloseTime1.Hour--;
  731.                                                          if(CloseTime1.Hour<0)
  732.                                                          {
  733.                                                                  CloseTime1.Hour = 23;
  734.                                                          }                                         
  735.                                                          LCD_Write_Char(11,1,CloseTime1.Hour/10+0x30);       
  736.                                                          LCD_Write_Char(12,1,CloseTime1.Hour%10+0x30);                                                         
  737.                                                    LCD_Write_Com(0xc0+12);
  738.                                           }
  739.                                                 if(lcdPoint2 == 11)
  740.                                           {
  741.                                                          CloseTime1.Minute--;
  742.                                                          if(CloseTime1.Minute<0)
  743.                                                          {
  744.                                                                  CloseTime1.Minute = 59;
  745.                                                          }                                         
  746.                                                          LCD_Write_Char(14,1,CloseTime1.Minute/10+0x30);       
  747.                                                          LCD_Write_Char(15,1,CloseTime1.Minute%10+0x30);                                                                                                                 
  748.                                                    LCD_Write_Com(0xc0+15);
  749.                                           }                                                                                                        
  750.                                                            
  751.                  }
  752.                         if(disMode == 2)                 //顯示開關燈時間2
  753.                  {
  754.                                                 if(lcdPoint3 == 1)         //指向星期1使能位
  755.                                          {
  756.                                                  WeekENA2.Mon = !WeekENA2.Mon;
  757.                                                  LCD_Write_Char(6,0,WeekENA2.Mon+0x30);
  758.                                                  LCD_Write_Com(0x80+6);         
  759.                                                 }
  760.                                                 if(lcdPoint3 == 2)         //指向星期2使能位
  761.                                          {
  762.                                                  WeekENA2.Tue = !WeekENA2.Tue;
  763.                                                  LCD_Write_Char(7,0,WeekENA2.Tue+0x30);
  764.                                                  LCD_Write_Com(0x80+7);         
  765.                                                 }
  766.                                                 if(lcdPoint3 == 3)         //指向星期3使能位
  767.                                          {
  768.                                                  WeekENA2.Wed = !WeekENA2.Wed;
  769.                                                  LCD_Write_Char(8,0,WeekENA2.Wed+0x30);
  770.                                                  LCD_Write_Com(0x80+8);         
  771.                                                 }
  772.                                                 if(lcdPoint3 == 4)         //指向星期4使能位
  773.                                          {
  774.                                                  WeekENA2.Thu = !WeekENA2.Thu;
  775.                                                  LCD_Write_Char(9,0,WeekENA2.Thu+0x30);
  776.                                                  LCD_Write_Com(0x80+9);         
  777.                                                 }
  778.                                                 if(lcdPoint3 == 5)         //指向星期5使能位
  779.                                          {
  780.                                                  WeekENA2.Fri = !WeekENA2.Fri;
  781.                                                  LCD_Write_Char(10,0,WeekENA2.Fri+0x30);
  782.                                                  LCD_Write_Com(0x80+10);         
  783.                                                 }
  784.                                                 if(lcdPoint3 == 6)         //指向星期6使能位
  785.                                          {
  786.                                                  WeekENA2.Sat = !WeekENA2.Sat;
  787.                                                  LCD_Write_Char(11,0,WeekENA2.Sat+0x30);
  788.                                                  LCD_Write_Com(0x80+11);         
  789.                                                 }
  790.                                                 if(lcdPoint3 == 7)         //指向星期7使能位
  791.                                          {
  792.                                                  WeekENA2.Sun = !WeekENA2.Sun;
  793.                                                  LCD_Write_Char(12,0,WeekENA2.Sun+0x30);
  794.                                                  LCD_Write_Com(0x80+12);         
  795.                                                 }
  796.                                                
  797.                                           if(lcdPoint3 == 8)
  798.                                                  {
  799.                                                          OpenTime2.Hour--;
  800.                                                          if(OpenTime2.Hour<0)
  801.                                                          {
  802.                                                                  OpenTime2.Hour = 23;
  803.                                                          }                                         
  804.                                                          LCD_Write_Char(2,1,OpenTime2.Hour/10+0x30);       
  805.                                                          LCD_Write_Char(3,1,OpenTime2.Hour%10+0x30);                                                         
  806.                                                          LCD_Write_Com(0xc0+3);
  807.                                                  }
  808.                                           if(lcdPoint3 == 9)
  809.                                                 {
  810.                                                          OpenTime2.Minute--;
  811.                                                          if(OpenTime2.Minute<0)
  812.                                                          {
  813.                                                                  OpenTime2.Minute = 59;
  814.                                                          }                                         
  815.                                                          LCD_Write_Char(5,1,OpenTime2.Minute/10+0x30);       
  816.                                                          LCD_Write_Char(6,1,OpenTime2.Minute%10+0x30);                                                         
  817.                                              LCD_Write_Com(0xc0+6);
  818.                                                 }
  819.                                                 if(lcdPoint3 == 10)
  820.                                           {
  821.                                                          CloseTime2.Hour--;
  822.                                                          if(CloseTime2.Hour<0)
  823.                                                          {
  824.                                                                  CloseTime2.Hour = 23;
  825.                                                          }                                         
  826.                                                          LCD_Write_Char(11,1,CloseTime2.Hour/10+0x30);       
  827.                                                          LCD_Write_Char(12,1,CloseTime2.Hour%10+0x30);                                                         
  828.                                                    LCD_Write_Com(0xc0+12);
  829.                                           }
  830.                                                 if(lcdPoint3 == 11)
  831.                                           {
  832.                                                          CloseTime2.Minute--;
  833.                                                          if(CloseTime2.Minute<0)
  834.                                                          {
  835.                                                                  CloseTime2.Minute = 59;
  836.                                                          }                                         
  837.                                                          LCD_Write_Char(14,1,CloseTime2.Minute/10+0x30);       
  838.                                                          LCD_Write_Char(15,1,CloseTime2.Minute%10+0x30);                                                                                                                 
  839.                                                    LCD_Write_Com(0xc0+15);
  840.                                           }                                                        
  841.                 }
  842.         }
  843.        
  844.         if(keyValue == 4) //按下了翻頁按鍵 ,用于調整顯示的內容,只在設置模式里起作用
  845.         {  
  846.                
  847.                 disMode++;
  848.                 if(disMode>2)
  849.                 {
  850.                         disMode = 0;
  851.                 }
  852.                 if(disMode == 0)
  853.                 {
  854.                         LCD_Clear();
  855.                         LCD_Const0();
  856.                         LCD_Write_Char(14,1,'C');
  857.             LCD_Write_Char(15,1,'F');       
  858.                         LCD_DIS_CurrenTime();      //顯示當前時間
  859.                         LCD_Write_Com(0x80+1);       
  860.                         lcdPoint1 = 1;
  861.                 }
  862.                 if(disMode == 1)
  863.                 {
  864.                         LCD_Clear();
  865.                         LCD_Const1();

  866.                         LCD_Write_Char(6,0,WeekENA1.Mon+0x30);
  867.                         LCD_Write_Char(7,0,WeekENA1.Tue+0x30);
  868.                         LCD_Write_Char(8,0,WeekENA1.Wed+0x30);
  869.                         LCD_Write_Char(9,0,WeekENA1.Thu+0x30);
  870.                         LCD_Write_Char(10,0,WeekENA1.Fri+0x30);
  871.                         LCD_Write_Char(11,0,WeekENA1.Sat+0x30);
  872.                         LCD_Write_Char(12,0,WeekENA1.Sun+0x30);

  873.                         LCD_Write_Char(2,1,OpenTime1.Hour/10+0x30);
  874.                         LCD_Write_Char(3,1,OpenTime1.Hour%10+0x30);       
  875.                         LCD_Write_Char(5,1,OpenTime1.Minute/10+0x30);
  876.                         LCD_Write_Char(6,1,OpenTime1.Minute%10+0x30);       
  877.                        
  878.                         LCD_Write_Char(11,1,CloseTime1.Hour/10+0x30);
  879.                         LCD_Write_Char(12,1,CloseTime1.Hour%10+0x30);       
  880.                         LCD_Write_Char(14,1,CloseTime1.Minute/10+0x30);
  881.                         LCD_Write_Char(15,1,CloseTime1.Minute%10+0x30);
  882.                        
  883.       LCD_Write_Com(0x80+6);
  884.                         lcdPoint2 = 1;
  885.                 }
  886.                 if(disMode == 2)
  887.                 {
  888.                         LCD_Clear();
  889.                         LCD_Const2();
  890.                        
  891.                         LCD_Write_Char(6,0,WeekENA2.Mon+0x30);
  892.                         LCD_Write_Char(7,0,WeekENA2.Tue+0x30);
  893.                         LCD_Write_Char(8,0,WeekENA2.Wed+0x30);
  894.                         LCD_Write_Char(9,0,WeekENA2.Thu+0x30);
  895.                         LCD_Write_Char(10,0,WeekENA2.Fri+0x30);
  896.                         LCD_Write_Char(11,0,WeekENA2.Sat+0x30);
  897.                         LCD_Write_Char(12,0,WeekENA2.Sun+0x30);
  898.                        
  899.                   LCD_Write_Char(2,1,OpenTime2.Hour/10+0x30);
  900.                         LCD_Write_Char(3,1,OpenTime2.Hour%10+0x30);       
  901.                         LCD_Write_Char(5,1,OpenTime2.Minute/10+0x30);
  902.                         LCD_Write_Char(6,1,OpenTime2.Minute%10+0x30);                                       
  903.                         LCD_Write_Char(11,1,CloseTime2.Hour/10+0x30);
  904.                         LCD_Write_Char(12,1,CloseTime2.Hour%10+0x30);       
  905.                         LCD_Write_Char(14,1,CloseTime2.Minute/10+0x30);
  906.                         LCD_Write_Char(15,1,CloseTime2.Minute%10+0x30);
  907.                         LCD_Write_Com(0x80+6);
  908.                         lcdPoint3 = 1;
  909.                 }
  910.         }
  911.        
  912.         if(keyValue == 6)  //按下確認按鍵
  913.         {
  914.                 workMode = 1;
  915.                 LCD_Write_Com(0x0c);    /*顯示開及光標設置*/
  916.                 LCD_Clear();
  917.                 LCD_Const0();
  918.                 Ds1302_Set_CurrentTime();
  919.                 relayMode = 0;
  920.                 disMode = 0;
  921.                 lcdPoint1 = 0;   
  922.     lcdPoint2 = 0;   
  923.     lcdPoint3 = 0;
  924.         }
  925.        
  926. }


  927. void Read_Time(void)    //讀取時間
  928. {
  929.          uchar Curtime[7];
  930.          v_Get1302(Curtime);
  931.    CurrentTime.Second = bcdtodec(Curtime[0]);
  932.    CurrentTime.Minute = bcdtodec(Curtime[1]);
  933.    CurrentTime.Hour = bcdtodec(Curtime[2]);
  934.    CurrentTime.Day = bcdtodec(Curtime[3]);
  935.    CurrentTime.Month = bcdtodec(Curtime[4]);
  936.          CurrentTime.Week = Conver_week(CurrentTime.Year,CurrentTime.Month,CurrentTime.Day); //自動計算星期
  937.        
  938.          //CurrentTime.Week = bcdtodec(Curtime[5]);
  939.    CurrentTime.Year = bcdtodec(Curtime[6]);
  940. }


  941. void LCD_DIS_CurrenTime()   //LCD顯示當前時間
  942. {

  943.          LCD_Write_Char(0,0,CurrentTime.Hour/10+0x30);
  944.          LCD_Write_Char(1,0,CurrentTime.Hour%10+0x30);

  945.          LCD_Write_Char(3,0,CurrentTime.Minute/10+0x30);
  946.          LCD_Write_Char(4,0,CurrentTime.Minute%10+0x30);
  947.        
  948.          LCD_Write_Char(6,0,CurrentTime.Second/10+0x30);
  949.          LCD_Write_Char(7,0,CurrentTime.Second%10+0x30);

  950.          LCD_Write_Char(13,0,CurrentTime.Week+0x30);
  951.        
  952.          LCD_Write_Char(0,1,CurrentTime.Year/10+0x30);
  953.          LCD_Write_Char(1,1,CurrentTime.Year%10+0x30);

  954.          LCD_Write_Char(3,1,CurrentTime.Month/10+0x30);
  955.          LCD_Write_Char(4,1,CurrentTime.Month%10+0x30);
  956.        
  957.          LCD_Write_Char(6,1,CurrentTime.Day/10+0x30);
  958.          LCD_Write_Char(7,1,CurrentTime.Day%10+0x30);       
  959. }

  960. void LCD_Const0()    //顯示固定的東西,只需要顯示一次
  961. {
  962.          char *s = "Mode:Au";
  963.          LCD_Write_Char(2,0,'-');
  964.          LCD_Write_Char(5,0,'-');
  965.          LCD_Write_Char(10,0,'W');
  966.          LCD_Write_Char(11,0,'-');
  967.          LCD_Write_Char(12,0,'<');
  968.          LCD_Write_Char(14,0,'>');
  969.          
  970.          LCD_Write_Char(2,1,'-');               
  971.          LCD_Write_Char(5,1,'-');       
  972.          LCD_Write_String(9,1,s);
  973. }

  974. void LCD_Const1()    //顯示固定的東西,只需要顯示一次
  975. {
  976.          LCD_Write_Char(0,0,'0');
  977.          LCD_Write_Char(1,0,'1');
  978.          LCD_Write_Char(2,0,':');
  979.          LCD_Write_Char(4,1,'-');
  980.        
  981.          LCD_Write_Char(0,1,'S');               
  982.          LCD_Write_Char(1,1,':');       
  983.          LCD_Write_Char(9,1,'X');
  984.          LCD_Write_Char(10,1,':');
  985.          LCD_Write_Char(13,1,'-');
  986. }

  987. void LCD_Const2()    //顯示固定的東西,只需要顯示一次
  988. {
  989.          LCD_Write_Char(0,0,'0');
  990.          LCD_Write_Char(1,0,'2');
  991.          LCD_Write_Char(2,0,':');
  992.          LCD_Write_Char(4,1,'-');
  993.          
  994.          LCD_Write_Char(0,1,'S');               
  995.          LCD_Write_Char(1,1,':');       
  996.          LCD_Write_Char(9,1,'X');
  997.          LCD_Write_Char(10,1,':');
  998.         LCD_Write_Char(13,1,'-');
  999. }

  1000. void Ds1302_Set_CurrentTime(void)
  1001. {
  1002.           T_RST = 0;                        //RST腳置低
  1003.     T_CLK = 0;                        //SCK腳置低
  1004.                 v_W1302(0x8e,0x00);

  1005.           Write_DS1302Init(CurrentTime.Year,CurrentTime.Month,CurrentTime.Day,CurrentTime.Week,CurrentTime.Hour,CurrentTime.Minute,CurrentTime.Second);

  1006.                 v_W1302(0x8e,0x80); //打開寫保護
  1007. }
復制代碼


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏2 分享淘帖 頂 踩
回復

使用道具 舉報

沙發
ID:128463 發表于 2017-1-9 11:35 | 只看該作者
謝謝分享!!!
回復

使用道具 舉報

板凳
ID:161441 發表于 2017-1-13 18:07 | 只看該作者
值得一看?
回復

使用道具 舉報

地板
ID:408157 發表于 2018-10-23 20:51 | 只看該作者
這是個好東西,可惜我不是看得很懂。原諒我51學得還不夠好
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表