欧美性猛交xxxx免费看_牛牛在线视频国产免费_天堂草原电视剧在线观看免费_国产粉嫩高清在线观看_国产欧美日本亚洲精品一5区

電子發(fā)燒友App

硬聲App

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示
創(chuàng)作
電子發(fā)燒友網(wǎng)>電子資料下載>電子資料>用于激活設(shè)備的可編程定時(shí)器-第二部分

用于激活設(shè)備的可編程定時(shí)器-第二部分

2022-12-13 | zip | 0.30 MB | 次下載 | 免費(fèi)

資料介紹

描述

介紹

在本文的第一部分,我們展示了如何創(chuàng)建所有流程來實(shí)現(xiàn)這個(gè)項(xiàng)目。您可以訪問鏈接中的第一部分(訪問文章的第一部分

現(xiàn)在,通過第二部分,我們將介紹創(chuàng)建功能以編程時(shí)鐘和日期以及編程設(shè)備激活時(shí)間的所有過程。

因此,通過這些功能,我們將了解實(shí)時(shí)時(shí)鐘 (RTC) DS1307的幾個(gè)應(yīng)用原理和使用方法。

項(xiàng)目的擬議職能

根據(jù)第一部分的解釋,該項(xiàng)目的目標(biāo)是在用戶設(shè)定的時(shí)間內(nèi)激活和停用設(shè)備。

因此,根據(jù)問題,需要使用CHIP Real-Time Clock 。CHIP 用于計(jì)算 7 個(gè)變量:秒、分、小時(shí)、凌晨、月日、月和年。因此,為此,需要實(shí)施一個(gè)小時(shí)制,以便用戶調(diào)整小時(shí)、日期、激活和停用時(shí)間。

為此,將根據(jù)第一部分所示的圖表實(shí)現(xiàn)幾個(gè)功能來解決這個(gè)問題。因此,我們將開發(fā)配置實(shí)時(shí)時(shí)鐘的實(shí)際時(shí)間和日期以及小時(shí)以激活設(shè)備的功能連接在繼電器中。

下文將介紹圖 2 中的電路原理圖和為項(xiàng)目第二部分開發(fā)的代碼。

?
pYYBAGOX29KAGOitAAGm3nvlkVo553.png
圖 2 - 第一部分項(xiàng)目的電子示意圖。
?

項(xiàng)目開發(fā)

首先,我們將通過變量創(chuàng)建和設(shè)備初始化來介紹配置過程。

因此,在進(jìn)入 void setup() 之前,包含所有庫、變量和函數(shù)原型。因此,請(qǐng)參見實(shí)現(xiàn)了三個(gè)功能:ReadKeypad、AdjustHour 和 ActivationHour。

此后每個(gè)函數(shù)指定如下:

  • ReadKeyPad() :執(zhí)行鍵盤按鈕的讀取,并通過此鍵盤使用數(shù)字及其字母。“A”字母用于調(diào)整小時(shí),“C”用于清除小時(shí)信息,“D”作為完成參數(shù)配置的按鍵。
  • AdjustTime() :負(fù)責(zé)調(diào)整DS1307的內(nèi)部日期和時(shí)間;
  • ActivationHour() :用于調(diào)整小時(shí)以激活連接在繼電器中的設(shè)備。
#include <DS1307.h>
#include <Wire.h>
#include <EEPROM.h>
#include <LiquidCrystal.h>
  
#define MEMORY 100
  
const int rs = 2, en = 3, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
  
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
char tempo[9] = "";
char data[9] = "";
int DataTime[7];
byte SegAnt = 0, SegAtual = 0;
  
byte ReadKeyPad(void);
void AdjustTime(void);
void ActivationHour(void);
  
void setup()
{
     Serial.begin(9600);
     DS1307.begin();
  
     //Config pins to control columns of the matrix keyboard
     for(int key = 8; key < 12; key++)
     {
       pinMode(key, OUTPUT);  
     }
  
     //Config pins to read lines of the matrix keyboard
     for(int key = 12; key < 16; key++)
     {
       pinMode(key, INPUT);  
     }
  
     for(int key = 8; key < 12; key++)
     {
       digitalWrite(key, LOW);  
     }
  
     lcd.begin(16,2);
}

在原型聲明之后,初始化設(shè)備RTC DS1307LCD 16x2并配置Arduino所有引腳。

現(xiàn)在,我們將通過函數(shù) void loop() 了解該系統(tǒng)的邏輯編程是如何工作的。

項(xiàng)目主要邏輯

首先,當(dāng)系統(tǒng)在循環(huán)函數(shù)開始時(shí)執(zhí)行初始化過程的驗(yàn)證。該驗(yàn)證由如下所示的第一個(gè)條件表示。

if(EEPROM.read(MEMORY) != 73)

這樣,系統(tǒng)就驗(yàn)證了用戶是第一次進(jìn)入系統(tǒng)。如果 EEPROM(位置 100)的讀取數(shù)與 73 不同,則需要配置系統(tǒng)的時(shí)間和日期。

因此,在配置好時(shí)間和日期后,系統(tǒng)將 73 值寫入 EEPROM。

EEPROM.write(MEMORIA, 73);

此數(shù)字用于向用戶發(fā)出信號(hào),表明時(shí)間和日期已配置。

void loop()
{
   if(EEPROM.read(MEMORIA) != 73)
   {
     AjustarHora();
     EEPROM.write(MEMORIA, 73);
     lcd.clear();
     ActivationHour();
   }
  
   DS1307.getDate(DataTime);    
   SegAtual = DataTime[6];
   
   if(LerTeclado() == 10)
   {
     AjustarHora();
     lcd.clear();
     ActivationHour();
     lcd.clear();
   }
   
   if(abs(SegAtual - SegAnt) >= 1)
   {
   
   sprintf(tempo, "%02d:%02d:%02d", DataTime[4], DataTime[5], DataTime[6]);
   sprintf(data, "%02d/%02d/%02d", DataTime[2], DataTime[1], DataTime[0]);
  
   lcd.setCursor(4,1);
   lcd.print(tempo);
   lcd.setCursor(4,0);
   lcd.print(data);
   SegAnt = SegAtual;
   
   }
}

此后,日期和時(shí)間的所有 7 個(gè)參數(shù)都被獲取并存儲(chǔ)在 DataTime 向量中。

獲取后,秒的值存儲(chǔ)在變量 SegAtual 中。此變量用于存儲(chǔ)秒的值。命令如下所示。

DS1307.getDate(DataTime);
SegAtual = DataTime[6];

現(xiàn)在,將執(zhí)行條件以了解用戶是否按下“A”鍵來調(diào)整時(shí)鐘時(shí)間和設(shè)備的激活時(shí)間。

按鍵“A”用10表示,是按下“A”時(shí)函數(shù)的返回值,如下所示。

if(LerTeclado() == 10)
{
   AjustarHora();
   lcd.clear();
   ActivationHour();
   lcd.clear();
}

最后,小時(shí)和數(shù)據(jù)顯示在LCD 顯示屏上。為了顯示小時(shí)和日期,執(zhí)行以下條件。

if(abs(SegAtual - SegAnt) >= 1)
{
   sprintf(tempo, "%02d:%02d:%02d", DataTime[4], DataTime[5], DataTime[6]);
   sprintf(data, "%02d/%02d/%02d", DataTime[2], DataTime[1], DataTime[0]);
   lcd.setCursor(4,1);
   lcd.print(tempo);
   lcd.setCursor(4,0);
   lcd.print(data);
   SegAnt = SegAtual;
}

因此,通過這個(gè)條件,日期和小時(shí)將每隔一秒出現(xiàn)在LCD上,如圖 3 所示。

?
poYBAGOX2-KACSunAAGE0e2K5lQ32.jpeg
圖 3 - LCD 中顯示的小時(shí)和日期。
?

現(xiàn)在,將解釋調(diào)整時(shí)間和調(diào)整小時(shí)以激活連接在繼電器上的設(shè)備的功能。

調(diào)整設(shè)備時(shí)鐘和激活時(shí)間的功能

首先,功能非常相似,現(xiàn)在,您將看到每個(gè)功能的工作原理。這樣,我們將分析 AdjustTime() 函數(shù)。

調(diào)整時(shí)間功能

現(xiàn)在,使用我們的函數(shù),我們將看到該函數(shù)的某些部分在整個(gè)函數(shù)中重復(fù)出現(xiàn),您將看到該函數(shù)分為兩部分:

  • 插入時(shí)鐘的小時(shí)和分鐘,
  • 插入月、月、年數(shù)據(jù);

首先,我們創(chuàng)建函數(shù)中使用的所有變量。

void AdjustTime()
{
  
  int times[6];
  int  DadosTempo[7];
  bool controle = 0;
  bool EstadoSobe = 0, EstadoDesce = 0;
  byte cont = 0;
  byte number = 0;
  int digitos[6];
  byte PosCursor = 0;
  byte t = 0;
  bool Validate = 0;
  char tempo[7] = "";
  char data[15] = "";
  
  DS1307.getDate(DadosTempo);
  
  sprintf(tempo, "%02d:%02dh", DadosTempo[4], DadosTempo[5]);
  sprintf(data, "%02d/%02d/%02d", DadosTempo[2], DadosTempo[1], DadosTempo[0]);
  
        times[4] = DadosTempo[4];
        times[5] = DadosTempo[5];
        times[3] = DadosTempo[3];
        times[2] = DadosTempo[2];
        times[1] = DadosTempo[1];
        times[0] = DadosTempo[0];
        times[6] = DadosTempo[6];
  
        digitos[0] = times[4]/10; //Armazena a Dezena das Horas
        digitos[1] = times[4]%10; //Armazena a Unidade das Horas
        digitos[2] = times[5]/10; //Armazena a Dezena dos Minutos
        digitos[3] = times[5]%10; //Armazena a Unidade dos Minutos
  
        do
        {
            lcd.setCursor(0,0);
            lcd.print("                ");
            lcd.setCursor(2,0);  
            lcd.print("Adjust hour:");
            lcd.setCursor(0,1);
            lcd.print("                ");
            lcd.setCursor(5,1);
            lcd.print(tempo);
            PosCursor = 5;
  
          do
          {
            number = ReadKeyPad();
            delay(100);
  
            if( (number >= 0 && number <= 9) && (controle == 0) && (cont < 4) )
            {
  
              digitos[cont] = number;  
              cont++;
              controle = 1;
              lcd.setCursor(PosCursor,1);
              lcd.print(number);                
              PosCursor++;
  
              if(cont == 2 || cont == 4)
              {
                PosCursor = PosCursor + 1;
              }
  
            }
  
            if(number == 16 && controle == 1)
            {
              controle = 0;
            }
  
            if(number == 12)
            { 
                for(cont = 0; cont < 4; cont++)
                {
                  digitos[cont] = 0;
                }  
              lcd.setCursor(0,1);
              lcd.print("                ");
              lcd.setCursor(5,1);
              lcd.print("00:00h");
              PosCursor = 5;
              cont = 0;
              for(int i = 4; i < 6; i++)
              {
                times[i] = 0;  
              }
            }
  
          }while(number != 13);  
  
          times[4] = (digitos[0]*10) + digitos[1];
          times[5] = (digitos[2]*10) + digitos[3];
  
          if((times[4] < 0 || times[4] > 23) || (times[5] < 0 || times[5] > 59))
          {
            lcd.clear();
            lcd.setCursor(4,0);
            lcd.print("Invalid");
            lcd.setCursor(6,1);  
            lcd.print("Hour");
            delay(2000);
  
            Validate = 1;
  
            lcd.clear();
            lcd.setCursor(0,0);
            lcd.print("                ");
            lcd.setCursor(1,0);  
            lcd.print("Adjust Hours:");
            lcd.setCursor(0,1);
            lcd.print("                ");
            lcd.setCursor(5,1);
            lcd.print("00:00h");
  
            sprintf(tempo, "%02d:%02dh", 0, 0);
  
            PosCursor = 5;
            cont = 0;
  
              for(int i = 0; i < 4; i++)
              {
                times[i] = 0;  
              }   
          }
        }while(Validate == 1);
  
            do
            {
              number = ReadKeyPad();
              delay(200);
            }while(number != 16);
/*--------------------------------Date Configuration--------------------------------*/
          
          PosCursor = 4;
          
          do
          {
            //Transformacao dos digitos da data para dezenas e unidades
            digitos[0] = times[2]/10; //Armazena a Dezena da Data
            digitos[1] = times[2]%10; //Armazena a Unidade da Data
            digitos[2] = times[1]/10; //Armazena a Dezena do Mes
            digitos[3] = times[1]%10; //Armazena a Unidade do Mes
            digitos[4] = times[0]/10; //Armazena a Dezena do Ano
            digitos[5] = times[0]%10; //Armazena a Unidade do Ano
  
            sprintf(data, "%02d/%02d/%02d", times[2], times[1], times[0]);
  
              lcd.setCursor(0,0);
              lcd.print("                ");
              lcd.setCursor(2,0);  
              lcd.print("Adjust Date:");           
              lcd.setCursor(0,1);
              lcd.print("                ");
              lcd.setCursor(4,1);
              lcd.print(data);
  
              PosCursor = 4;
              cont = 0;
  
            do
            {
            number = ReadKeyPad();
            delay(100);
  
            if( (number >= 0 && number <= 9) && (controle == 0) && (cont < 6) )
            {
              digitos[cont] = number;
              cont++;
              controle = 1;              
              lcd.setCursor(PosCursor,1);
              lcd.print(number);                
              PosCursor++;
              if(cont == 2 || cont == 4)
              {
                PosCursor = PosCursor + 1;
              }
            }
  
            if(number == 16 && controle == 1)
            {
              controle = 0;
            }
  
            if(number == 12)
            { 
                for(cont = 0; cont < 6; cont++)
                {
                  digitos[cont] = 0;
                }  
              lcd.setCursor(0,1);
              lcd.print("                ");
              lcd.setCursor(4,1);
              lcd.print("00/00/00");
              PosCursor = 4;
              cont = 0;
            }
          }while(number != 13);
  
          times[2] = (digitos[0]*10) + digitos[1]; //Transformando os numeros lidos para data do mes em dois dígitos
          times[1] = (digitos[2]*10) + digitos[3]; //Transformando os numeros lidos para mes em dois dígitos
          times[0] = (digitos[4]*10) + digitos[5]; //Transformando os numeros lidos para ano em dois dígitos
  
          if((times[2] <= 0 || times[2] > 31) || (times[1] <= 0 || times[1] > 12) || times[0] <= 0)
          {
              lcd.clear();
              lcd.setCursor(4,0);
              lcd.print("Invalid");
              lcd.setCursor(6,1);  
              lcd.print("Date");
              delay(2000);
              Validate = 1;
              lcd.clear();
              lcd.setCursor(0,0);
              lcd.print("                ");
              lcd.setCursor(2,0);  
              lcd.print("Adjuste Date:");           
              lcd.setCursor(0,1);
              lcd.print("                ");
              lcd.setCursor(3,1);
              lcd.print("00/00/00");
              PosCursor = 5;
              cont = 0;
                for(byte i = 0; i < 3; i++)
                {
                  times[i] = 0;  
                }
         } 
        }while(Validate == 1);
  
        do
        {
          number = ReadKeyPad();
          delay(200);
        }while(number != 16);
  
         lcd.clear();
  
         DS1307.setDate(times[0],times[1],times[2],times[3],times[4],times[5],00);//year,month,date of month, day of week,hour,minutes,second
}

此后,DS1307的功能是獲取數(shù)據(jù)并存儲(chǔ)在DadosTempo 中,然后將值拆分并打印在字符串“tempo”和“data”中。這兩個(gè)字符串用于在LCD后面打印其信息。

DS1307.getDate(DadosTempo);
   
sprintf(tempo, "%02d:%02dh", DadosTempo[4], DadosTempo[5]);
sprintf(data, "%02d/%02d/%02d", DadosTempo[2], DadosTempo[1], DadosTempo[0]);

矢量“DadosTempo”的數(shù)據(jù)被分離并存儲(chǔ)在矢量時(shí)間中。向量“times”將用于接收副本并操作“DadosTempo”向量的數(shù)據(jù)。

緊接著,times[4] 和 times[5] 將被分成十位和個(gè)位,在時(shí)間設(shè)置中進(jìn)行操作。

times[4] = DadosTempo[4];
         times[5] = DadosTempo[5];
         times[3] = DadosTempo[3];
         times[2] = DadosTempo[2];
         times[1] = DadosTempo[1];
         times[0] = DadosTempo[0];
         times[6] = DadosTempo[6];
   
         digitos[0] = times[4]/10; //Store ten of hours
         digitos[1] = times[4]%10; //Store unit of hours
         digitos[2] = times[5]/10; //Store ten of minutes
         digitos[3] = times[5]%10; //Store unit of minutes

之后,系統(tǒng)會(huì)根據(jù)下面的代碼顯示消息“Adjust Hour:”并在第二行顯示“tempo”字符串的內(nèi)容。

lcd.setCursor(0,0);
         lcd.print("                ");
         lcd.setCursor(2,0);  
         lcd.print("Adjust hour:");
  
         lcd.setCursor(0,1);
         lcd.print("                ");
         lcd.setCursor(5,1);
         lcd.print(tempo);
  
         PosCursor = 5;

圖 4 顯示了LCD 顯示屏中顯示的消息。

?
poYBAGOX2_CARjQ-AAFiw_TMX-M37.jpeg
圖 4 - 調(diào)整時(shí)間消息。
?

一旦消息在LCD中打印,系統(tǒng)就會(huì)開始讀取過程以驗(yàn)證用戶按下的鍵是什么。這個(gè)過程由下面的代碼表示。

do
           {
  
             number = ReadKeyPad();
             delay(100);
  
             if( (number >= 0 && number <= 9) && (controle == 0) && (cont < 4) )
             {
               digitos[cont] = number;  
               cont++;
               controle = 1;
  
               lcd.setCursor(PosCursor,1);
               lcd.print(number);                
               PosCursor++;
  
               if(cont == 2 || cont == 4)
               {
                 PosCursor = PosCursor + 1;
               }
             }
  
             if(number == 16 && controle == 1)
             {
               controle = 0;
             }
  
             if(number == 12)
             { 
  
                 for(cont = 0; cont < 4; cont++)
                 {
                   digitos[cont] = 0;
                 }  
  
               lcd.setCursor(0,1);
               lcd.print("                ");
               lcd.setCursor(5,1);
               lcd.print("00:00h");
  
               PosCursor = 5;
               cont = 0;
  
               for(int i = 4; i < 6; i++)
               {
                 times[i] = 0;  
               }
             }
  
           }while(number != 13);

首先,系統(tǒng)讀取鍵盤并將值存儲(chǔ)在變量號(hào)中,然后驗(yàn)證如下所示的條件。

if( (number >= 0 && number <= 9) && (controle == 0) && (cont < 4) )

根據(jù)條件,它驗(yàn)證了三個(gè)重要點(diǎn)

  • 驗(yàn)證一個(gè)數(shù)字是否在 0 到 9之間
  • 驗(yàn)證變量“controle”是否等于 0。該變量用于允許條件僅一次為真,并且僅讀取一次該數(shù)字。
  • 驗(yàn)證變量“cont”是否小于 4。此變量用于允許用戶僅輸入 4位數(shù)字:兩位數(shù)表示小時(shí),兩位數(shù)表示分鐘。

這樣,當(dāng)條件為真時(shí),數(shù)字存儲(chǔ)在數(shù)字向量中并打印在LCD中。在此之后,變量“PosCursor”被遞增到指向單位位置。

如果 cont 變量等于 2 或 cont 等于 4,則光標(biāo)位置再次增加,因?yàn)椤埃骸毙盘?hào)。這樣,光標(biāo)將指向分鐘的小數(shù)位。

現(xiàn)在,如果上述條件不成立,則將驗(yàn)證以下條件。如果用戶按下任何鍵,函數(shù)“LerTeclado()”返回?cái)?shù)字 16 表示沒有按下任何鍵。

if(number == 16 && controle == 1)
{
  controle = 0;
}

因此,如果此條件為真,系統(tǒng)將在變量“controle”處歸零。此變量用于控制在接收用戶按下的 0 到 9 之間的數(shù)字的條件下的訪問。

最后,我們要檢查最后一個(gè)條件。如果按下“C”鍵,則返回值為 13。

因此,通過此鍵,系統(tǒng)將清除小時(shí)的值,以允許用戶再次輸入新的值。這可以在圖 5 中看到。

?
poYBAGOX2_mALOphAAGh8xTWXSQ91.jpeg
圖 5 - LCD 的清晰屏幕。
?

當(dāng)用戶插入錯(cuò)誤值并需要輸入新值時(shí),這很有用,如圖 6 所示。

?
pYYBAGOX3AKAOYpHAAF5LvNHq_k96.jpeg
圖 6 - 插入了錯(cuò)誤的時(shí)間。
?

現(xiàn)在,查看“do while”循環(huán)的條件。系統(tǒng)在do-while中運(yùn)行,直到用戶按下“D”鍵(Done),它由值13表示。

該鍵用于在系統(tǒng)中通知用戶已插入值。

}while(number != 13);

此后,用戶輸入的數(shù)字將以小時(shí)和十位為單位,如下面的代碼所示。

times[4] = (digitos[0]*10) + digitos[1];
times[5] = (digitos[2]*10) + digitos[3];
  
 if((times[4] < 0 || times[4] > 23) || (times[5] < 0 || times[5] > 59))
 {
    lcd.clear();
    lcd.setCursor(4,0);
    lcd.print("Invalid");
    lcd.setCursor(6,1);  
    lcd.print("Hour");
    delay(2000);
  
    Validate = 1;
  
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("                ");
    lcd.setCursor(1,0);  
    lcd.print("Adjust Hours:");
  
    lcd.setCursor(0,1);
    lcd.print("                ");
    lcd.setCursor(5,1);
    lcd.print("00:00h");
  
    sprintf(tempo, "%02d:%02dh", 0, 0);
  
    PosCursor = 5;
    cont = 0;
  
    for(byte i = 0; i < 4; i++)
    {
        times[i] = 0;  
    }   
 }
  
}while(Validate == 1);

最后,我們有最后一個(gè)條件。最后一個(gè)條件用于驗(yàn)證用戶輸入的小時(shí)和分鐘。

如果用戶輸入的值錯(cuò)誤,布爾變量 Validate 將收到 1。該值將向系統(tǒng)發(fā)出信號(hào),表明某些值錯(cuò)誤并顯示“無效時(shí)間”消息,如圖 7 所示。

?
poYBAGOX3AyABD6TAAFum_7tza487.jpeg
圖 7 - 無效的小時(shí)信息。
?

因此,系統(tǒng)將需要接收新的正確值。但是,如果值是正確的,系統(tǒng)不會(huì)進(jìn)入該條件并通過函數(shù)的第二部分:接收日期的數(shù)據(jù)。

設(shè)置日期的過程

以同樣的形式,當(dāng)我們配置時(shí)鐘數(shù)據(jù)時(shí),我們將設(shè)置日期。過程類似。它具有接收號(hào)碼的過程,數(shù)字錯(cuò)誤時(shí)的擦除功能以及用戶輸入的號(hào)碼的驗(yàn)證過程。

最后,配置完所有參數(shù)后,就有了實(shí)時(shí)時(shí)鐘芯片的參數(shù)發(fā)送功能,如下圖所示。

DS1307.setDate(times[0],times[1],times[2],times[3],times[4],times[5],00);//year,month,date of month, day of week,hour,minutes,second

通過這個(gè)函數(shù),RTC 配置了小時(shí)和日期的參數(shù)。此后,系統(tǒng)返回 void 循環(huán)函數(shù)。

在您返回 void 循環(huán)函數(shù)后,LCD 屏幕將被擦除并調(diào)用 ActiveHour 函數(shù)。

void ActivationHour(void)
{
  int times[6];
  int  DadosTempo[7];
  bool controle = 0;
  bool EstadoSobe = 0, EstadoDesce = 0;
  byte cont = 0;
  byte number = 0;
  int digitos[6];
  byte PosCursor = 0;
  bool Validate = 0;
  lcd.clear();
  
        for(byte i = 0; i < 6; i++)
        {
          digitos[i] = 0;
        }
  
        do
        {  
            lcd.setCursor(0,0);
            lcd.print("                ");
            lcd.setCursor(0,0);  
            lcd.print("Activation Hour:");
            lcd.setCursor(0,1);
            lcd.print("                ");
            lcd.setCursor(5,1);
            lcd.print("00:00h");
            PosCursor = 5;
  
          do
          {
            number = ReadKeyPad();
            delay(100);
  
            if( (number >= 0 && number <= 9) && (controle == 0) && (cont < 4) )
            {
  
              digitos[cont] = number;  
              cont++;
              controle = 1;
              lcd.setCursor(PosCursor,1);
              lcd.print(number);                
              PosCursor++;
  
              if(cont == 2 || cont == 4)
              {
                PosCursor = PosCursor + 1;
              }
  
            }
  
            if(number == 16 && controle == 1)
            {
              controle = 0;
            }
  
            if(number == 12)
            { 
               for(cont = 0; cont < 4; cont++)
               {
                  digitos[cont] = 0;
               }  
  
               lcd.setCursor(0,1);
               lcd.print("                ");
               lcd.setCursor(5,1);
               lcd.print("00:00h");
               PosCursor = 5;
               cont = 0;
  
               for(int i = 4; i < 6; i++)
               {
                 times[i] = 0;  
               }
           }
          }while(number != 13);  
  
          times[4] = (digitos[0]*10) + digitos[1];
          times[5] = (digitos[2]*10) + digitos[3];
  
          if((times[4] < 0 || times[4] > 23) || (times[5] < 0 || times[5] > 59))
          {
            lcd.clear();
            lcd.setCursor(3,0);
            lcd.print("Invalid");
            lcd.setCursor(4,1);  
            lcd.print("Hour");
            delay(2000);
  
            Validate = 1;
  
            lcd.clear();
            lcd.setCursor(0,0);
            lcd.print("                ");
            lcd.setCursor(1,0);  
            lcd.print("Activation Hour:");
  
            lcd.setCursor(0,1);
            lcd.print("                ");
            lcd.setCursor(5,1);
            lcd.print("00:00h");
  
            sprintf(tempo, "%02d:%02dh", 0, 0);
  
            PosCursor = 5;
            cont = 0;
  
            for(cont = 0; cont < 4; cont++)
            {
              digitos[cont] = 0;
            }  
          }
        }while(Validate == 1);
  
        EEPROM.write(1, times[4]);
        EEPROM.write(2, times[5]);
  
            do
            {
              number = ReadKeyPad();
              delay(200);
            }while(number != 16);
}

HourActivate 函數(shù)與設(shè)置 RTC 時(shí)鐘的函數(shù)類似。唯一的區(qū)別是小時(shí)和分鐘的值存儲(chǔ)在 EEPROM 存儲(chǔ)器中,如下所示。

EEPROM.write(1, times[4]);
EEPROM.write(2, times[5]);

這些值存儲(chǔ)在 EEPROM 存儲(chǔ)器中,以便在初始化系統(tǒng)開始時(shí)讀取。因此,通過這些值,將有可能與時(shí)鐘進(jìn)行比較,并在編程時(shí)間啟動(dòng)設(shè)備。

函數(shù) HourActivation 完全執(zhí)行后,系統(tǒng)返回 void 循環(huán)函數(shù),并顯示文章開頭所示的日期和小時(shí)。

現(xiàn)在,將在下一篇文章 - 第三部分中解釋新功能。

下一個(gè)要實(shí)現(xiàn)的功能

通過到目前為止已實(shí)現(xiàn)的功能,在第三部分中,我們將實(shí)現(xiàn)新功能以提高我們的工作質(zhì)量。下文將介紹新功能:

  • 實(shí)現(xiàn) DeactivationHour() 函數(shù);
  • 實(shí)現(xiàn)一個(gè)邏輯系統(tǒng)來比較時(shí)鐘以激活和停用連接在繼電器中的設(shè)備;
  • 實(shí)現(xiàn)信號(hào)化以指示按下的鍵。

?


下載該資料的人也在下載 下載該資料的人還在閱讀
更多 >

評(píng)論

查看更多

下載排行

本周

  1. 1山景DSP芯片AP8248A2數(shù)據(jù)手冊(cè)
  2. 1.06 MB  |  532次下載  |  免費(fèi)
  3. 2RK3399完整板原理圖(支持平板,盒子VR)
  4. 3.28 MB  |  339次下載  |  免費(fèi)
  5. 3TC358743XBG評(píng)估板參考手冊(cè)
  6. 1.36 MB  |  330次下載  |  免費(fèi)
  7. 4DFM軟件使用教程
  8. 0.84 MB  |  295次下載  |  免費(fèi)
  9. 5元宇宙深度解析—未來的未來-風(fēng)口還是泡沫
  10. 6.40 MB  |  227次下載  |  免費(fèi)
  11. 6迪文DGUS開發(fā)指南
  12. 31.67 MB  |  194次下載  |  免費(fèi)
  13. 7元宇宙底層硬件系列報(bào)告
  14. 13.42 MB  |  182次下載  |  免費(fèi)
  15. 8FP5207XR-G1中文應(yīng)用手冊(cè)
  16. 1.09 MB  |  178次下載  |  免費(fèi)

本月

  1. 1OrCAD10.5下載OrCAD10.5中文版軟件
  2. 0.00 MB  |  234315次下載  |  免費(fèi)
  3. 2555集成電路應(yīng)用800例(新編版)
  4. 0.00 MB  |  33566次下載  |  免費(fèi)
  5. 3接口電路圖大全
  6. 未知  |  30323次下載  |  免費(fèi)
  7. 4開關(guān)電源設(shè)計(jì)實(shí)例指南
  8. 未知  |  21549次下載  |  免費(fèi)
  9. 5電氣工程師手冊(cè)免費(fèi)下載(新編第二版pdf電子書)
  10. 0.00 MB  |  15349次下載  |  免費(fèi)
  11. 6數(shù)字電路基礎(chǔ)pdf(下載)
  12. 未知  |  13750次下載  |  免費(fèi)
  13. 7電子制作實(shí)例集錦 下載
  14. 未知  |  8113次下載  |  免費(fèi)
  15. 8《LED驅(qū)動(dòng)電路設(shè)計(jì)》 溫德爾著
  16. 0.00 MB  |  6656次下載  |  免費(fèi)

總榜

  1. 1matlab軟件下載入口
  2. 未知  |  935054次下載  |  免費(fèi)
  3. 2protel99se軟件下載(可英文版轉(zhuǎn)中文版)
  4. 78.1 MB  |  537798次下載  |  免費(fèi)
  5. 3MATLAB 7.1 下載 (含軟件介紹)
  6. 未知  |  420027次下載  |  免費(fèi)
  7. 4OrCAD10.5下載OrCAD10.5中文版軟件
  8. 0.00 MB  |  234315次下載  |  免費(fèi)
  9. 5Altium DXP2002下載入口
  10. 未知  |  233046次下載  |  免費(fèi)
  11. 6電路仿真軟件multisim 10.0免費(fèi)下載
  12. 340992  |  191187次下載  |  免費(fèi)
  13. 7十天學(xué)會(huì)AVR單片機(jī)與C語言視頻教程 下載
  14. 158M  |  183279次下載  |  免費(fèi)
  15. 8proe5.0野火版下載(中文版免費(fèi)下載)
  16. 未知  |  138040次下載  |  免費(fèi)