電力を節約するか、電気ネットワークの夜間料金のタイマーを使用します

どのくらいの頻度で異なるタイマーを設定する必要がありますか? スマートフォンの目覚まし時計、朝食用の焼きたてのパンがあるようにパンメーカーのタイマー、そしてあなたはあなたが何かを開始する必要があるのか​​分からない。 重要なことは、時間内にアクションを切断または完了するタスクです。



そのため、電化製品の組み込みとシャットダウンを自動化するタスクに直面しました。 タイムリレー付きの標準ソケットを使用することは可能ですが、異常な負荷をオンにする必要があるため、コントローラーとコントローラーのみがオンになります。



したがって、タスクは、電気暖房ボイラーをオンにして、夜間に家屋を暖房し、料金が少なくとも少し節約されるようにすることです。 これの由来-以下を参照してください。



画像



イベントをトリガーするために、または時間内に必要な連絡先を閉じる6〜8千ルーブルの既製のタイムリレーを購入することは、単にスポーツマンらしくありません。 さらに、同様の機能を備えたコントローラー、または十分な機能マージンを備えたコントローラーでも、脳のウォームアップはもちろんのこと、4倍のコストがかかります。 すべてはお正月に始まりました。



厳密に割り当てられた時間で作業するためには、現在の時間を把握し、作業の境界を設定する必要があります。 すべてがうまくいきますが、作業時間を変更し、時には時計を調整することをお勧めします。 さらに、コンピューターを使用してパラメーターを変更する必要のないエンドデバイスの形式でタスクを実装する方が便利です。 また、追加の機能がコントローラーにハングアップしますが、これはバージョン2.0ですが、現時点ではタイムタイマーです。



ここから、タスクを完了するために必要なデバイスのリストが決定されました。



1. Arduino Nano(モジュールが安価であるほど、タスクはリソース集約型ではないため、より良い);

2. RTC時間モジュール。

3.リレーモジュール(2つのリレー);

4. arduino用の電源アダプター。 DC-DCコンバーター-スタビライザー12V-5Vが選択されました。

5.美しさのための4x20文字ディスプレイ(4行と2行の文字が利用可能);

6.ディスプレイ用のI2Cアダプター。



そのため、結果として接続されることが判明しました。



画像



すべてをブレッドボードにまとめるのは簡単でした。 Habrを勉強して、私はずっと前にI2Cバスで仕事をしていることに気づき、友人の時計のデザインが本当に好きだったので、彼のコードの一部を借りて、同じスタイルのメインクロックを作りました。



次に、EEPROMとクロックモジュールの使用方法を研究する長いプロセスがありました。これにより、電源が落ちたときに、タイムタイマーとクロック自体が迷子にならないようにします。 最初は時計がオフになりましたが、フォーラムを長時間調査した結果、RTCモジュールにはLi-IONバッテリーが搭載されており、中国からロシアへの長距離旅行で座っただけであることがわかりました。 数日間の食事のサポートは退院を埋めることができ、より多くの時間が迷子になりませんでした。



すべてのモジュールをより強力に接続し、コードを記述し、デバッグを開始することが残っています。



スケッチ時間リレー
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib #include <EEPROM.h> #include <Wire.h> #include <DS1307.h> #include "RTClib.h" #include <LiquidCrystal_I2C.h> #define timePIN 10 #define RELE_1 12 //  1    7 #define RELE_2 11 //  2    8 //  A4  SDA   SDA  //  A5  SCL   SCL  int FullMinutesTimerOn = EEPROM.read(0); int FullMinutesTimerOff = EEPROM.read(2); int rtc[7]; byte rr[7]; int ledPin = 13; LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display int button1 = 10; //   D10 int button2 = 9; //   D9 int button3 = 8; //   D8 int button4 = 7; //   D7 int button5 = 6; //   D6 int led = 5; int rejim=0; //     int PrevSec=0; int CurSec=0; boolean lastButton=LOW; byte LT[8] = { B00111, B01111, B11111, B11111, B11111, B11111, B11111, B11111 }; byte UB[8] = { B11111, B11111, B11111, B00000, B00000, B00000, B00000, B00000 }; byte RT[8] = { B11100, B11110, B11111, B11111, B11111, B11111, B11111, B11111 }; byte LL[8] = { B11111, B11111, B11111, B11111, B11111, B11111, B01111, B00111 }; byte LB[8] = { B00000, B00000, B00000, B00000, B00000, B11111, B11111, B11111 }; byte LR[8] = { B11111, B11111, B11111, B11111, B11111, B11111, B11110, B11100 }; byte MB[8] = { B11111, B11111, B11111, B00000, B00000, B00000, B11111, B11111 }; byte block[8] = { B11111, B11111, B11111, B11111, B11111, B11111, B11111, B11111 }; // loop counter int count = 0; void setup () { DDRC|=_BV(2) |_BV(3); // POWER:Vcc Gnd PORTC |=_BV(3); // VCC PINC3 pinMode(ledPin, OUTPUT); pinMode(timePIN, OUTPUT); pinMode(RELE_1, OUTPUT); //     pinMode(RELE_2, OUTPUT); //     digitalWrite(RELE_1, HIGH); //    digitalWrite(RELE_2, HIGH); //    RTC.get(rtc,true); lcd.init(); // initialize the lcd lcd.backlight(); lcd.home(); lcd.createChar(0,LT); lcd.createChar(1,UB); lcd.createChar(2,RT); lcd.createChar(3,LL); lcd.createChar(4,LB); lcd.createChar(5,LR); lcd.createChar(6,MB); lcd.createChar(7,block); // sets the LCD's rows and colums: lcd.clear(); RTC.SetOutput(DS1307_SQW32KHZ); pinMode(led, OUTPUT); pinMode(button1, INPUT); pinMode(button2, INPUT); pinMode(button3, INPUT); } void custom0(int x) { // uses segments to build the number 0 lcd.setCursor(x,0); // set cursor to column 0, line 0 (first row) lcd.write(0); // call each segment to create lcd.write(1); // top half of the number lcd.write(2); lcd.setCursor(x, 1); // set cursor to colum 0, line 1 (second row) lcd.write(3); // call each segment to create lcd.write(4); // bottom half of the number lcd.write(5); } void custom1(int x) { lcd.setCursor(x,0); lcd.write(1); lcd.write(2); lcd.print(" "); lcd.setCursor(x,1); lcd.write(4); lcd.write(7); lcd.write(4); } void custom2(int x) { lcd.setCursor(x,0); lcd.write(6); lcd.write(6); lcd.write(2); lcd.setCursor(x, 1); lcd.write(3); lcd.write(4); lcd.write(4); } void custom3(int x) { lcd.setCursor(x,0); lcd.write(6); lcd.write(6); lcd.write(2); lcd.setCursor(x, 1); lcd.write(4); lcd.write(4); lcd.write(5); } void custom4(int x) { lcd.setCursor(x,0); lcd.write(3); lcd.write(4); lcd.write(7); lcd.setCursor(x, 1); lcd.print(" "); lcd.print(" "); lcd.write(7); } void custom5(int x) { lcd.setCursor(x,0); lcd.write(3); lcd.write(6); lcd.write(6); lcd.setCursor(x, 1); lcd.write(4); lcd.write(4); lcd.write(5); } void custom6(int x) { lcd.setCursor(x,0); lcd.write(0); lcd.write(6); lcd.write(6); lcd.setCursor(x, 1); lcd.write(3); lcd.write(4); lcd.write(5); } void custom7(int x) { lcd.setCursor(x,0); lcd.write(1); lcd.write(1); lcd.write(2); lcd.setCursor(x, 1); lcd.print(" "); lcd.print(" "); lcd.write(7); } void custom8(int x) { lcd.setCursor(x,0); lcd.write(0); lcd.write(6); lcd.write(2); lcd.setCursor(x, 1); lcd.write(3); lcd.write(4); lcd.write(5); } void custom9(int x) { lcd.setCursor(x,0); lcd.write(0); lcd.write(6); lcd.write(2); lcd.setCursor(x, 1); lcd.print(" "); lcd.print(" "); lcd.write(7); } void digitalClockDisplay(){ // digital clock display of the time printDigits(rtc[2]/10,0); printDigits(rtc[2]%10,4); printDigits(rtc[1]/10,9); printDigits(rtc[1]%10,13); if (rtc[0]%10%2==0){ lcd.setCursor(7, 0); lcd.print("+ "); lcd.setCursor(7, 1); lcd.print(" +"); lcd.setCursor(3, 1); lcd.print("+"); lcd.setCursor(12, 0); lcd.print("+"); lcd.setCursor(3, 0); lcd.print(" "); lcd.setCursor(12, 1); lcd.print(" "); } else { lcd.setCursor(7, 0); lcd.print(" +"); lcd.setCursor(7, 1); lcd.print("+ "); lcd.setCursor(3, 0); lcd.print("+"); lcd.setCursor(12, 1); lcd.print("+"); lcd.setCursor(3, 1); lcd.print(" "); lcd.setCursor(12, 0); lcd.print(" "); } //  } void printDigits(int digits, int x){ // utility function for digital clock display: prints preceding colon and leading 0 switch (digits) { case 0: custom0(x); break; case 1: custom1(x); break; case 2: custom2(x); break; case 3: custom3(x); break; case 4: custom4(x); break; case 5: custom5(x); break; case 6: custom6(x); break; case 7: custom7(x); break; case 8: custom8(x); break; case 9: custom9(x); break; } } void loop () { int hourOn=EEPROM.read(110); //EEPROM.read(110) int hourOff= EEPROM.read(112);; //EEPROM.read(112) int minOn= EEPROM.read(111);; //EEPROM.read(111) int minOff= EEPROM.read(113);; //EEPROM.read(113) int Hour = rtc[2]; //  int Minute = rtc[1]; //  int Second = rtc[0]; //   int FullMinutes = Hour * 60 + Minute; //      int FullMinutesTimerOn= hourOn*60+minOn; //      int FullMinutesTimerOff= hourOff*60+minOff; //      int sutki=0; //  ,      if (hourOff-hourOn < 0) sutki=1; //     ,    =1 else sutki=0; if (sutki==1 && (FullMinutes >= FullMinutesTimerOn || FullMinutes <= FullMinutesTimerOff) ) { lcd.setCursor(16, 2); lcd.print("VKL1"); digitalWrite(RELE_1, LOW); //   ,      } else if (sutki==1) { lcd.print(" "); digitalWrite(RELE_1, HIGH); } if (sutki == 0 && (FullMinutes >= FullMinutesTimerOn && FullMinutes <= FullMinutesTimerOff )) { lcd.setCursor(16, 2); lcd.print("VKL0"); digitalWrite(RELE_1, LOW); } //    ,      else if (sutki == 0) { lcd.print(" "); digitalWrite(RELE_1, HIGH); } RTC.get(rtc,true); digitalClockDisplay(); //    2  strokatimera(); if (rejim==0) { lcd.setCursor(0, 2); lcd.print ("ojidayu komandi"); } if (rejim==1) { setTimerOn(); } if (rejim==2) { setTimerOff(); } if (rejim==3) { setTime(); } if (digitalRead (button5) == HIGH) { rejim++; if (rejim>3) rejim=0; lcd.clear(); //} } } void setTimerOn() { int hourOn= EEPROM.read(110); int minOn= EEPROM.read(111); lcd.setCursor(0, 2); lcd.print("nastroika VKL"); if (digitalRead(button3)==HIGH) //     { hourOn++; if (hourOn >=24) hourOn=0; } if (!digitalRead(button4)) //     { minOn++; if (minOn >=60) { minOn=0; hourOn++; if (hourOn >=24) hourOn=0; } } strokatimera(); if (digitalRead(button2) == HIGH) { EEPROM.write(110, hourOn); EEPROM.write(111, minOn); lcd.clear(); } } void setTimerOff() { int hourOff= EEPROM.read(112); int minOff= EEPROM.read(113); lcd.setCursor(0, 2); lcd.print("nastroika VIKL"); if (digitalRead(button3)==HIGH) //     { hourOff++; if (hourOff >=24) hourOff=0; } if (!digitalRead(button4)) //     { minOff++; if (minOff >=60) { minOff=0; hourOff++; if (hourOff >=24) hourOff=0; } } strokatimera(); if (digitalRead(button2) == HIGH) { EEPROM.write(112, hourOff); EEPROM.write(113, minOff); lcd.clear(); } } void setTime() { lcd.setCursor(0, 2); //lcd.print ("nastroika time_test"); lcd.print ("pustaya nastroika"); } void strokatimera() { int hourOn=EEPROM.read(110); //EEPROM.read(110) int hourOff= EEPROM.read(112);; //EEPROM.read(112) int minOn= EEPROM.read(111);; //EEPROM.read(111) int minOff= EEPROM.read(113);; //EEPROM.read(113) lcd.setCursor(0, 3); //        lcd.print(hourOn); lcd.print(":"); lcd.print(minOn); lcd.print("-"); lcd.print(hourOff); lcd.print(":"); lcd.print(minOff); }
      
      







そして、これがどのように機能するかです:







コントローラーが分と時間を変更するために個々のボタンを押すことに応答したくないが、分を変更する別のボタンを押すことに喜んで応答する理由は私には謎のままです。 これに基づいて、タイマーの最初のリリースを起動する必要があり、残りは後で処理する必要があるため、コードをヒンドゥー教徒の状態に仕上げました。 これらの接点への標準の点滅出力は通常のピン電圧を与えますが、はんだ付けの際に過熱すると罪を犯します。 現時点では、ピンD6で変更メニューに入ることができ、ピンD9で数分スクロールします。 似たようなものに出会った場合、誰かに教えてもらえますか



PSすでに記事を書いた後、コントローラーに割り当てられたタスクを拡張する必要があるという事実に直面しました。 実際、このコントローラーはカントリーハウスの電気ボイラーを制御し、温度が上昇すると湿度が上昇し始めました。 換気システムにこれと同様のチャンネルファンを追加する必要がありました。



画像



...そして、2番目のリレーに掛けます。 特定の期間、1時間ごとにオンにすることが最も成功することが実験的に確立されました。 同時に、それは9から21時間だけオンになり、夜には家からの熱は追い出されません。 オンタイム調整もボタンで実行されますが、動作時間はプログラムに組み込まれています。 現時点では、フードは1時間ごとに10分間オンになります。 バスルームまたはトイレの照明が点灯したときにフードを自動的にオンにするための予備が残っています。

1か月間自信を持って機能している現在のコードは次のとおりです。



有効なコード
 // Date and time functions using a DS1307 RTC connected via I2C and Wire lib #include <EEPROM.h> #include <Wire.h> #include <DS1307.h> #include "RTClib.h" #include <LiquidCrystal_I2C.h> //#define timePIN 10 #define RELE_1 12 //  1    7 #define RELE_2 11 //  2    8 //  A4  SDA   SDA  //  A5  SCL   SCL  int FullMinutesTimerOn = EEPROM.read(0); int FullMinutesTimerOff = EEPROM.read(2); int rtc[7]; byte rr[7]; int ledPin = 13; LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display int button1 = 10; //   D10 int button2 = 9; //   D9 int button3 = 8; //   D8 int button4 = 7; //   D7 int button5 = 6; //   D6 int led = 5; int rejim=0; //     int PrevSec=0; int CurSec=0; boolean lastButton=LOW; byte LT[8] = { B00111, B01111, B11111, B11111, B11111, B11111, B11111, B11111 }; byte UB[8] = { B11111, B11111, B11111, B00000, B00000, B00000, B00000, B00000 }; byte RT[8] = { B11100, B11110, B11111, B11111, B11111, B11111, B11111, B11111 }; byte LL[8] = { B11111, B11111, B11111, B11111, B11111, B11111, B01111, B00111 }; byte LB[8] = { B00000, B00000, B00000, B00000, B00000, B11111, B11111, B11111 }; byte LR[8] = { B11111, B11111, B11111, B11111, B11111, B11111, B11110, B11100 }; byte MB[8] = { B11111, B11111, B11111, B00000, B00000, B00000, B11111, B11111 }; byte block[8] = { B11111, B11111, B11111, B11111, B11111, B11111, B11111, B11111 }; // loop counter int count = 0; void setup () { DDRC|=_BV(2) |_BV(3); // POWER:Vcc Gnd PORTC |=_BV(3); // VCC PINC3 pinMode(ledPin, OUTPUT); //pinMode(timePIN, OUTPUT); pinMode(RELE_1, OUTPUT); //     pinMode(RELE_2, OUTPUT); //     digitalWrite(RELE_1, HIGH); //    digitalWrite(RELE_2, HIGH); //    RTC.get(rtc,true); lcd.init(); // initialize the lcd lcd.backlight(); lcd.home(); lcd.createChar(0,LT); lcd.createChar(1,UB); lcd.createChar(2,RT); lcd.createChar(3,LL); lcd.createChar(4,LB); lcd.createChar(5,LR); lcd.createChar(6,MB); lcd.createChar(7,block); // sets the LCD's rows and colums: lcd.clear(); RTC.SetOutput(DS1307_SQW32KHZ); pinMode(led, OUTPUT); pinMode(button1, INPUT); pinMode(button2, INPUT); pinMode(button3, INPUT); } void custom0(int x) { // uses segments to build the number 0 lcd.setCursor(x,0); // set cursor to column 0, line 0 (first row) lcd.write(0); // call each segment to create lcd.write(1); // top half of the number lcd.write(2); lcd.setCursor(x, 1); // set cursor to colum 0, line 1 (second row) lcd.write(3); // call each segment to create lcd.write(4); // bottom half of the number lcd.write(5); } void custom1(int x) { lcd.setCursor(x,0); lcd.write(1); lcd.write(2); lcd.print(" "); lcd.setCursor(x,1); lcd.write(4); lcd.write(7); lcd.write(4); } void custom2(int x) { lcd.setCursor(x,0); lcd.write(6); lcd.write(6); lcd.write(2); lcd.setCursor(x, 1); lcd.write(3); lcd.write(4); lcd.write(4); } void custom3(int x) { lcd.setCursor(x,0); lcd.write(6); lcd.write(6); lcd.write(2); lcd.setCursor(x, 1); lcd.write(4); lcd.write(4); lcd.write(5); } void custom4(int x) { lcd.setCursor(x,0); lcd.write(3); lcd.write(4); lcd.write(7); lcd.setCursor(x, 1); lcd.print(" "); lcd.print(" "); lcd.write(7); } void custom5(int x) { lcd.setCursor(x,0); lcd.write(3); lcd.write(6); lcd.write(6); lcd.setCursor(x, 1); lcd.write(4); lcd.write(4); lcd.write(5); } void custom6(int x) { lcd.setCursor(x,0); lcd.write(0); lcd.write(6); lcd.write(6); lcd.setCursor(x, 1); lcd.write(3); lcd.write(4); lcd.write(5); } void custom7(int x) { lcd.setCursor(x,0); lcd.write(1); lcd.write(1); lcd.write(2); lcd.setCursor(x, 1); lcd.print(" "); lcd.print(" "); lcd.write(7); } void custom8(int x) { lcd.setCursor(x,0); lcd.write(0); lcd.write(6); lcd.write(2); lcd.setCursor(x, 1); lcd.write(3); lcd.write(4); lcd.write(5); } void custom9(int x) { lcd.setCursor(x,0); lcd.write(0); lcd.write(6); lcd.write(2); lcd.setCursor(x, 1); lcd.print(" "); lcd.print(" "); lcd.write(7); } void digitalClockDisplay(){ // digital clock display of the time printDigits(rtc[2]/10,0); printDigits(rtc[2]%10,4); printDigits(rtc[1]/10,9); printDigits(rtc[1]%10,13); if (rtc[0]%10%2==0){ lcd.setCursor(7, 0); lcd.print("+ "); lcd.setCursor(7, 1); lcd.print(" +"); lcd.setCursor(3, 1); lcd.print("+"); lcd.setCursor(12, 0); lcd.print("+"); lcd.setCursor(3, 0); lcd.print(" "); lcd.setCursor(12, 1); lcd.print(" "); } else { lcd.setCursor(7, 0); lcd.print(" +"); lcd.setCursor(7, 1); lcd.print("+ "); lcd.setCursor(3, 0); lcd.print("+"); lcd.setCursor(12, 1); lcd.print("+"); lcd.setCursor(3, 1); lcd.print(" "); lcd.setCursor(12, 0); lcd.print(" "); } //  } void printDigits(int digits, int x){ // utility function for digital clock display: prints preceding colon and leading 0 switch (digits) { case 0: custom0(x); break; case 1: custom1(x); break; case 2: custom2(x); break; case 3: custom3(x); break; case 4: custom4(x); break; case 5: custom5(x); break; case 6: custom6(x); break; case 7: custom7(x); break; case 8: custom8(x); break; case 9: custom9(x); break; } } void loop () { int hourOn=EEPROM.read(110); //EEPROM.read(110) int hourOff= EEPROM.read(112);; //EEPROM.read(112) int minOn= EEPROM.read(111);; //EEPROM.read(111) int minOff= EEPROM.read(113);; //EEPROM.read(113) int minVent= EEPROM.read(114); //   int Hour = rtc[2]; //  int Minute = rtc[1]; //  int Second = rtc[0]; //   int FullMinutes = Hour * 60 + Minute; //      int FullMinutesTimerOn= hourOn*60+minOn; //      int FullMinutesTimerOff= hourOff*60+minOff; //      int sutki=0; //  ,      if (hourOff-hourOn < 0) sutki=1; //     ,    =1 else sutki=0; if (sutki==1 && (FullMinutes >= FullMinutesTimerOn || FullMinutes <= FullMinutesTimerOff) ) { lcd.setCursor(16, 2); lcd.print("VKL1"); digitalWrite(RELE_1, LOW); //   ,      } else if (sutki==1) { lcd.print(" "); digitalWrite(RELE_1, HIGH); } if (sutki == 0 && (FullMinutes >= FullMinutesTimerOn && FullMinutes <= FullMinutesTimerOff )) { lcd.setCursor(16, 2); lcd.print("VKL0"); digitalWrite(RELE_1, LOW); } //    ,      else if (sutki == 0) { lcd.print(" "); digitalWrite(RELE_1, HIGH); } if ((Minute >= 0 && Minute <= minVent) && (Hour >= 9 && Hour <= 21)) { lcd.setCursor(17, 1); lcd.print("VEN"); digitalWrite(RELE_2, LOW); } if (Minute >= 0 && Minute > minVent) { lcd.setCursor(17, 1); lcd.print(" "); digitalWrite(RELE_2, HIGH); } RTC.get(rtc,true); digitalClockDisplay(); //    2  strokatimera(); if (rejim==0) { lcd.setCursor(0, 2); lcd.print ("ojidayu komandi"); } if (rejim==1) { setTimerOn(); } if (rejim==2) { setTimerOff(); } if (rejim==3) { setTime(); } if (rejim==4) { setVent(); } if (digitalRead (button5) == HIGH) { rejim++; if (rejim>4) rejim=0; lcd.clear(); //} } } void setTimerOn() { int hourOn= EEPROM.read(110); int minOn= EEPROM.read(111); lcd.setCursor(0, 2); lcd.print("nastroika VKL"); if (digitalRead(button3)==HIGH) //     { hourOn++; if (hourOn >=24) hourOn=0; } if (!digitalRead(button4)) //     { minOn++; if (minOn >=60) { minOn=0; hourOn++; if (hourOn >=24) hourOn=0; } } strokatimera(); if (digitalRead(button2) == HIGH) { EEPROM.write(110, hourOn); EEPROM.write(111, minOn); lcd.clear(); } } void setTimerOff() { int hourOff= EEPROM.read(112); int minOff= EEPROM.read(113); lcd.setCursor(0, 2); lcd.print("nastroika VIKL"); if (digitalRead(button3)==HIGH) //     { hourOff++; if (hourOff >=24) hourOff=0; } if (!digitalRead(button4)) //     { minOff++; if (minOff >=60) { minOff=0; hourOff++; if (hourOff >=24) hourOff=0; } } strokatimera(); if (digitalRead(button2) == HIGH) { EEPROM.write(112, hourOff); EEPROM.write(113, minOff); lcd.clear(); } } void setTime() { int Hour = rtc[2]; //  int Minute = rtc[1]; //lcd.clear(); lcd.setCursor(0, 2); lcd.print ("nastroika time"); RTC.get(rtc,true); //lcd.setCursor(0, 3); //        // lcd.print(Hour); // lcd.print(":"); // lcd.print(Minute); if (!digitalRead(button4)) //     { Minute++; if (Minute >=60) { Minute=0; Hour++; if (Hour >=24) Hour=0; } } if (digitalRead(button2) == HIGH) { RTC.set(DS1307_MIN,Minute); RTC.set(DS1307_HR,Hour); lcd.clear(); } } void strokatimera() { int hourOn=EEPROM.read(110); //EEPROM.read(110) int hourOff= EEPROM.read(112);; //EEPROM.read(112) int minOn= EEPROM.read(111);; //EEPROM.read(111) int minOff= EEPROM.read(113);; //EEPROM.read(113) int minVent= EEPROM.read(114); lcd.setCursor(0, 3); //        lcd.print(hourOn); lcd.print(":"); lcd.print(minOn); lcd.print("-"); lcd.print(hourOff); lcd.print(":"); lcd.print(minOff); lcd.print(" "); lcd.print("VENT:"); lcd.print(minVent); } void setVent() { int minVent= EEPROM.read(114); lcd.setCursor(0, 2); lcd.print("nastroika Vent"); if (!digitalRead(button4)) //     { minVent++; if (minVent >=60) { minVent=0; } } strokatimera(); if (digitalRead(button2) == HIGH) { EEPROM.write(114, minVent); lcd.clear(); } }
      
      







将来、このコントローラーをOpenHabに接続して、自宅の暖房および換気システムをリモートで監視および制御することが計画されています。



ファームウェアバージョン1.1では、次のことができます。





毎日の仕事が追加されました
 // Date and time functions using a DS1307 RTC connected via I2C and Wire lib #include <EEPROM.h> #include <Wire.h> #include <DS1307.h> #include "RTClib.h" #include <LiquidCrystal_I2C.h> //#define timePIN 10 #define RELE_1 12 //  1    7 #define RELE_2 11 //  2    8 // //  A4  SDA   SDA  //  A5  SCL   SCL  int FullMinutesTimerOn = EEPROM.read(0); int FullMinutesTimerOff = EEPROM.read(2); int rtc[7]; byte rr[7]; int ledPin = 13; LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display int button1 = 10; //   D10 int button2 = 9; //   D9 int button3 = 8; //   D8 int button4 = 7; //   D7 int button5 = 6; //   D6 int led = 5; int rejim=0; //     int i=1; //       int PrevSec=0; int CurSec=0; int Day=0; boolean lastButton=LOW; byte LT[8] = { B00111, B01111, B11111, B11111, B11111, B11111, B11111, B11111 }; byte UB[8] = { B11111, B11111, B11111, B00000, B00000, B00000, B00000, B00000 }; byte RT[8] = { B11100, B11110, B11111, B11111, B11111, B11111, B11111, B11111 }; byte LL[8] = { B11111, B11111, B11111, B11111, B11111, B11111, B01111, B00111 }; byte LB[8] = { B00000, B00000, B00000, B00000, B00000, B11111, B11111, B11111 }; byte LR[8] = { B11111, B11111, B11111, B11111, B11111, B11111, B11110, B11100 }; byte MB[8] = { B11111, B11111, B11111, B00000, B00000, B00000, B11111, B11111 }; byte block[8] = { B11111, B11111, B11111, B11111, B11111, B11111, B11111, B11111 }; // loop counter int count = 0; void setup () { DDRC|=_BV(2) |_BV(3); // POWER:Vcc Gnd PORTC |=_BV(3); // VCC PINC3 pinMode(ledPin, OUTPUT); //pinMode(timePIN, OUTPUT); pinMode(RELE_1, OUTPUT); //     pinMode(RELE_2, OUTPUT); //     digitalWrite(RELE_1, HIGH); //    digitalWrite(RELE_2, HIGH); //    RTC.get(rtc,true); lcd.init(); // initialize the lcd lcd.backlight(); lcd.home(); lcd.createChar(0,LT); lcd.createChar(1,UB); lcd.createChar(2,RT); lcd.createChar(3,LL); lcd.createChar(4,LB); lcd.createChar(5,LR); lcd.createChar(6,MB); lcd.createChar(7,block); // sets the LCD's rows and colums: lcd.clear(); RTC.SetOutput(DS1307_SQW32KHZ); pinMode(led, OUTPUT); pinMode(button1, INPUT); pinMode(button2, INPUT); pinMode(button3, INPUT); } void custom0(int x) { // uses segments to build the number 0 lcd.setCursor(x,0); // set cursor to column 0, line 0 (first row) lcd.write(0); // call each segment to create lcd.write(1); // top half of the number lcd.write(2); lcd.setCursor(x, 1); // set cursor to colum 0, line 1 (second row) lcd.write(3); // call each segment to create lcd.write(4); // bottom half of the number lcd.write(5); } void custom1(int x) { lcd.setCursor(x,0); lcd.write(1); lcd.write(2); lcd.print(" "); lcd.setCursor(x,1); lcd.write(4); lcd.write(7); lcd.write(4); } void custom2(int x) { lcd.setCursor(x,0); lcd.write(6); lcd.write(6); lcd.write(2); lcd.setCursor(x, 1); lcd.write(3); lcd.write(4); lcd.write(4); } void custom3(int x) { lcd.setCursor(x,0); lcd.write(6); lcd.write(6); lcd.write(2); lcd.setCursor(x, 1); lcd.write(4); lcd.write(4); lcd.write(5); } void custom4(int x) { lcd.setCursor(x,0); lcd.write(3); lcd.write(4); lcd.write(7); lcd.setCursor(x, 1); lcd.print(" "); lcd.print(" "); lcd.write(7); } void custom5(int x) { lcd.setCursor(x,0); lcd.write(3); lcd.write(6); lcd.write(6); lcd.setCursor(x, 1); lcd.write(4); lcd.write(4); lcd.write(5); } void custom6(int x) { lcd.setCursor(x,0); lcd.write(0); lcd.write(6); lcd.write(6); lcd.setCursor(x, 1); lcd.write(3); lcd.write(4); lcd.write(5); } void custom7(int x) { lcd.setCursor(x,0); lcd.write(1); lcd.write(1); lcd.write(2); lcd.setCursor(x, 1); lcd.print(" "); lcd.print(" "); lcd.write(7); } void custom8(int x) { lcd.setCursor(x,0); lcd.write(0); lcd.write(6); lcd.write(2); lcd.setCursor(x, 1); lcd.write(3); lcd.write(4); lcd.write(5); } void custom9(int x) { lcd.setCursor(x,0); lcd.write(0); lcd.write(6); lcd.write(2); lcd.setCursor(x, 1); lcd.print(" "); lcd.print(" "); lcd.write(7); } void digitalClockDisplay(){ // digital clock display of the time printDigits(rtc[2]/10,0); printDigits(rtc[2]%10,4); printDigits(rtc[1]/10,9); printDigits(rtc[1]%10,13); if (rtc[0]%10%2==0){ lcd.setCursor(7, 0); lcd.print("+ "); lcd.setCursor(7, 1); lcd.print(" +"); lcd.setCursor(3, 1); lcd.print("+"); lcd.setCursor(12, 0); lcd.print("+"); lcd.setCursor(3, 0); lcd.print(" "); lcd.setCursor(12, 1); lcd.print(" "); } else { lcd.setCursor(7, 0); lcd.print(" +"); lcd.setCursor(7, 1); lcd.print("+ "); lcd.setCursor(3, 0); lcd.print("+"); lcd.setCursor(12, 1); lcd.print("+"); lcd.setCursor(3, 1); lcd.print(" "); lcd.setCursor(12, 0); lcd.print(" "); } //  } void printDigits(int digits, int x){ // utility function for digital clock display: prints preceding colon and leading 0 switch (digits) { case 0: custom0(x); break; case 1: custom1(x); break; case 2: custom2(x); break; case 3: custom3(x); break; case 4: custom4(x); break; case 5: custom5(x); break; case 6: custom6(x); break; case 7: custom7(x); break; case 8: custom8(x); break; case 9: custom9(x); break; } } void loop () { int hourOn=EEPROM.read(110); //EEPROM.read(110) int hourOff= EEPROM.read(112);; //EEPROM.read(112) int minOn= EEPROM.read(111);; //EEPROM.read(111) int minOff= EEPROM.read(113);; //EEPROM.read(113) int minVent= EEPROM.read(114); //   int rejimDay=0; int Day = rtc[3]; //  int Hour = rtc[2]; //  int Minute = rtc[1]; //  int Second = rtc[0]; //   int FullMinutes = Hour * 60 + Minute; //      int FullMinutesTimerOn= hourOn*60+minOn; //      int FullMinutesTimerOff= hourOff*60+minOff; //      int sutki=0; //  ,      lcd.setCursor(16, 0); lcd.print(Day); if (hourOff-hourOn < 0) sutki=1; //     ,    =1 else sutki=0; if (EEPROM.read(114+Day)==1 && sutki==1) { rejimDay=1; lcd.print("+"); } else { rejimDay=0; lcd.print("-"); } if (sutki==1 && (FullMinutes >= FullMinutesTimerOn || FullMinutes <= FullMinutesTimerOff) ) { lcd.setCursor(16, 2); lcd.print("VKL"); digitalWrite(RELE_1, LOW); //   ,      } else if (sutki==1) { lcd.print(" "); digitalWrite(RELE_1, HIGH); } if (sutki == 0 && (FullMinutes >= FullMinutesTimerOn && FullMinutes <= FullMinutesTimerOff )) { lcd.setCursor(16, 2); lcd.print("VKL"); digitalWrite(RELE_1, LOW); } //    ,      else if (sutki == 0) { lcd.print(" "); digitalWrite(RELE_1, HIGH); } if ((Minute >= 0 && Minute <= minVent) && (Hour >= 9 && Hour <= 21)) { lcd.setCursor(17, 1); lcd.print("VEN"); digitalWrite(RELE_2, LOW); } if (Minute >= 0 && Minute > minVent) { lcd.setCursor(17, 1); lcd.print(" "); digitalWrite(RELE_2, HIGH); } RTC.get(rtc,true); if (rejim==0) { lcd.setCursor(0, 2); lcd.print ("ojidayu komandi"); strokatimera(); digitalClockDisplay(); //    2  } if (rejim==1) { setTimerOn(); } if (rejim==2) { setTimerOff(); } if (rejim==3) { setTime(); } if (rejim==4) { setVent(); } if (rejim==5) { setTimerDay1(); } if (digitalRead (button5) == HIGH) { rejim++; delay(100); if (rejim>5) rejim=0; lcd.clear(); //} } } void setTimerOn() { int hourOn= EEPROM.read(110); int minOn= EEPROM.read(111); lcd.setCursor(0, 2); lcd.print("nastroika VKL"); if (digitalRead(button3)==HIGH) //     { hourOn++; if (hourOn >=24) hourOn=0; } if (digitalRead(button2)==HIGH) //     { minOn++; if (minOn >=60) { minOn=0; hourOn++; if (hourOn >=24) hourOn=0; } } strokatimera(); digitalClockDisplay(); if (digitalRead(button2) == HIGH) { EEPROM.write(110, hourOn); EEPROM.write(111, minOn); lcd.clear(); } } void setTimerOff() { int hourOff= EEPROM.read(112); int minOff= EEPROM.read(113); lcd.setCursor(0, 2); lcd.print("nastroika VIKL"); if (digitalRead(button3)==HIGH) //     { hourOff++; if (hourOff >=24) hourOff=0; } if (!digitalRead(button4)) //     { minOff++; if (minOff >=60) { minOff=0; hourOff++; if (hourOff >=24) hourOff=0; } } strokatimera(); digitalClockDisplay(); if (digitalRead(button2) == HIGH) { EEPROM.write(112, hourOff); EEPROM.write(113, minOff); lcd.clear(); } } void setTime() { int Hour = rtc[2]; //  int Minute = rtc[1]; //lcd.clear(); lcd.setCursor(0, 2); lcd.print ("nastroika time"); RTC.get(rtc,true); digitalClockDisplay(); //lcd.setCursor(0, 3); //        // lcd.print(Hour); // lcd.print(":"); // lcd.print(Minute); if (!digitalRead(button4)) //     { Minute++; if (Minute >=60) { Minute=0; Hour++; if (Hour >=24) Hour=0; } } if (digitalRead(button2) == HIGH) { RTC.set(DS1307_MIN,Minute); RTC.set(DS1307_HR,Hour); lcd.clear(); } } void strokatimera() { int hourOn=EEPROM.read(110); //EEPROM.read(110) int hourOff= EEPROM.read(112);; //EEPROM.read(112) int minOn= EEPROM.read(111);; //EEPROM.read(111) int minOff= EEPROM.read(113);; //EEPROM.read(113) int minVent= EEPROM.read(114); lcd.setCursor(0, 3); //        lcd.print(hourOn); lcd.print(":"); lcd.print(minOn); lcd.print("-"); lcd.print(hourOff); lcd.print(":"); lcd.print(minOff); lcd.print(" "); lcd.print("VENT:"); lcd.print(minVent); } void setVent() { strokatimera(); int minVent= EEPROM.read(114); lcd.setCursor(0, 2); lcd.print("nastroika Vent"); if (!digitalRead(button4)) //     { minVent++; if (minVent >=60) { minVent=0; } } digitalClockDisplay(); //    2  if (digitalRead(button2) == HIGH) { EEPROM.write(114, minVent); lcd.clear(); } } void setTimerDay1() { int z; //lcd.clear(); lcd.setCursor(0, 0); lcd.print ("nastroika dney"); //lcd.setCursor(0, 1); lcd.setCursor (0,3); lcd.print (EEPROM.read(115)); lcd.print (" "); lcd.print (EEPROM.read(116)); lcd.print (" "); lcd.print (EEPROM.read(117)); lcd.print (" "); lcd.print (EEPROM.read(118)); lcd.print (" "); lcd.print (EEPROM.read(119)); lcd.print (" "); lcd.print (EEPROM.read(120)); lcd.print (" "); lcd.print (EEPROM.read(121)); lcd.print (" "); //lcd.clear(); z=EEPROM.read(114+i); //     /   if (i==1) { lcd.setCursor(1, 2); lcd.print ("ponedelnik"); lcd.print (" "); lcd.print (z); } if (i==2) { lcd.setCursor(1, 2); lcd.print ("vtornik"); lcd.print (" "); lcd.print (z); } if (i==3) { lcd.setCursor(1, 2); lcd.print ("sreda"); lcd.print (" "); lcd.print (z); } if (i==4) { lcd.setCursor(1, 2); lcd.print ("chetverg"); lcd.print (" "); lcd.print (z); } if (i==5) { lcd.setCursor(1, 2); lcd.print ("pyatnica"); lcd.print (" "); lcd.print (z); } if (i==6) { lcd.setCursor(1, 2); lcd.print ("subbota"); lcd.print (" "); lcd.print (z); } if (i==7) { lcd.setCursor(1, 2); lcd.print ("voskresen'e"); lcd.print (" "); lcd.print (z); } if (digitalRead(button3)==HIGH) //   { lcd.clear(); i++; delay(150); if (i>7) {i=1;} } if (digitalRead(button2)==HIGH) { delay(150); z=!z; if (z!= EEPROM.read(114+i)) { EEPROM.write(114+i,z); } } }
      
      









ボンネットの通常の操作が激しい霜で家を著しく冷やし、建物の外に暖かい空気を放出するという事実に直面しました。 フードをオフにするメニュー項目を追加しました。 トイレとバスルームの照明をオンにするには、フードが常に機能しています。 ファームウェアのいくつかの点も修正しました。



シャットダウンフードを追加
 // Date and time functions using a DS1307 RTC connected via I2C and Wire lib #include <EEPROM.h> #include <Wire.h> #include <DS1307.h> #include "RTClib.h" #include <LiquidCrystal_I2C.h> //#define timePIN 10 #define RELE_1 11 //      #define RELE_2 12 //  ,   // //  A4  SDA   SDA  //  A5  SCL   SCL  int FullMinutesTimerOn = EEPROM.read(0); int FullMinutesTimerOff = EEPROM.read(2); int rtc[7]; byte rr[7]; int ledPin = 13; LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display int button1 = 10; //   D10 int button2 = 9; //   D9 int button3 = 8; //   D8 int button4 = 7; //   D7 int button5 = 6; //   D6 int vanna = 2; //     D2 int led = 5; int rejim=0; //     int i=1; //       int PrevSec=0; int CurSec=0; int Day=0; int vannatimer=0; boolean lastButton=LOW; byte LT[8] = { B00111, B01111, B11111, B11111, B11111, B11111, B11111, B11111 }; byte UB[8] = { B11111, B11111, B11111, B00000, B00000, B00000, B00000, B00000 }; byte RT[8] = { B11100, B11110, B11111, B11111, B11111, B11111, B11111, B11111 }; byte LL[8] = { B11111, B11111, B11111, B11111, B11111, B11111, B01111, B00111 }; byte LB[8] = { B00000, B00000, B00000, B00000, B00000, B11111, B11111, B11111 }; byte LR[8] = { B11111, B11111, B11111, B11111, B11111, B11111, B11110, B11100 }; byte MB[8] = { B11111, B11111, B11111, B00000, B00000, B00000, B11111, B11111 }; byte block[8] = { B11111, B11111, B11111, B11111, B11111, B11111, B11111, B11111 }; // loop counter int count = 0; void setup () { DDRC|=_BV(2) |_BV(3); // POWER:Vcc Gnd PORTC |=_BV(3); // VCC PINC3 pinMode(ledPin, OUTPUT); //pinMode(timePIN, OUTPUT); pinMode(RELE_1, OUTPUT); //     pinMode(RELE_2, OUTPUT); //     digitalWrite(RELE_1, HIGH); //    digitalWrite(RELE_2, HIGH); //    RTC.get(rtc,true); lcd.init(); // initialize the lcd lcd.backlight(); lcd.home(); lcd.createChar(0,LT); lcd.createChar(1,UB); lcd.createChar(2,RT); lcd.createChar(3,LL); lcd.createChar(4,LB); lcd.createChar(5,LR); lcd.createChar(6,MB); lcd.createChar(7,block); // sets the LCD's rows and colums: lcd.clear(); RTC.SetOutput(DS1307_SQW32KHZ); pinMode(led, OUTPUT); pinMode(button1, INPUT); pinMode(button2, INPUT); pinMode(button3, INPUT); pinMode(vanna, INPUT); //    - } void custom0(int x) { // uses segments to build the number 0 lcd.setCursor(x,0); // set cursor to column 0, line 0 (first row) lcd.write(0); // call each segment to create lcd.write(1); // top half of the number lcd.write(2); lcd.setCursor(x, 1); // set cursor to colum 0, line 1 (second row) lcd.write(3); // call each segment to create lcd.write(4); // bottom half of the number lcd.write(5); } void custom1(int x) { lcd.setCursor(x,0); lcd.write(1); lcd.write(2); lcd.print(" "); lcd.setCursor(x,1); lcd.write(4); lcd.write(7); lcd.write(4); } void custom2(int x) { lcd.setCursor(x,0); lcd.write(6); lcd.write(6); lcd.write(2); lcd.setCursor(x, 1); lcd.write(3); lcd.write(4); lcd.write(4); } void custom3(int x) { lcd.setCursor(x,0); lcd.write(6); lcd.write(6); lcd.write(2); lcd.setCursor(x, 1); lcd.write(4); lcd.write(4); lcd.write(5); } void custom4(int x) { lcd.setCursor(x,0); lcd.write(3); lcd.write(4); lcd.write(7); lcd.setCursor(x, 1); lcd.print(" "); lcd.print(" "); lcd.write(7); } void custom5(int x) { lcd.setCursor(x,0); lcd.write(3); lcd.write(6); lcd.write(6); lcd.setCursor(x, 1); lcd.write(4); lcd.write(4); lcd.write(5); } void custom6(int x) { lcd.setCursor(x,0); lcd.write(0); lcd.write(6); lcd.write(6); lcd.setCursor(x, 1); lcd.write(3); lcd.write(4); lcd.write(5); } void custom7(int x) { lcd.setCursor(x,0); lcd.write(1); lcd.write(1); lcd.write(2); lcd.setCursor(x, 1); lcd.print(" "); lcd.print(" "); lcd.write(7); } void custom8(int x) { lcd.setCursor(x,0); lcd.write(0); lcd.write(6); lcd.write(2); lcd.setCursor(x, 1); lcd.write(3); lcd.write(4); lcd.write(5); } void custom9(int x) { lcd.setCursor(x,0); lcd.write(0); lcd.write(6); lcd.write(2); lcd.setCursor(x, 1); lcd.print(" "); lcd.print(" "); lcd.write(7); } void digitalClockDisplay(){ // digital clock display of the time printDigits(rtc[2]/10,0); printDigits(rtc[2]%10,4); printDigits(rtc[1]/10,9); printDigits(rtc[1]%10,13); if (rtc[0]%10%2==0){ lcd.setCursor(7, 0); lcd.print("+ "); lcd.setCursor(7, 1); lcd.print(" +"); lcd.setCursor(3, 1); lcd.print("+"); lcd.setCursor(12, 0); lcd.print("+"); lcd.setCursor(3, 0); lcd.print(" "); lcd.setCursor(12, 1); lcd.print(" "); } else { lcd.setCursor(7, 0); lcd.print(" +"); lcd.setCursor(7, 1); lcd.print("+ "); lcd.setCursor(3, 0); lcd.print("+"); lcd.setCursor(12, 1); lcd.print("+"); lcd.setCursor(3, 1); lcd.print(" "); lcd.setCursor(12, 0); lcd.print(" "); } //  } void printDigits(int digits, int x){ // utility function for digital clock display: prints preceding colon and leading 0 switch (digits) { case 0: custom0(x); break; case 1: custom1(x); break; case 2: custom2(x); break; case 3: custom3(x); break; case 4: custom4(x); break; case 5: custom5(x); break; case 6: custom6(x); break; case 7: custom7(x); break; case 8: custom8(x); break; case 9: custom9(x); break; } } void loop () { int hourOn=EEPROM.read(110); //EEPROM.read(110) int hourOff= EEPROM.read(112);; //EEPROM.read(112) int minOn= EEPROM.read(111);; //EEPROM.read(111) int minOff= EEPROM.read(113);; //EEPROM.read(113) int minVent= EEPROM.read(114); //   int Vent= EEPROM.read(122); int rejimDay=0; int Day = rtc[3]; //  int Hour = rtc[2]; //  int Minute = rtc[1]; //  int Second = rtc[0]; //   int FullMinutes = Hour * 60 + Minute; //      int FullMinutesTimerOn= hourOn*60+minOn; //      int FullMinutesTimerOff= hourOff*60+minOff; //      int sutki=0; //  ,      //if (digitalRead (vanna) == HIGH) //           //{ // digitalWrite(RELE_2, LOW); //digitalWrite(ledPin, HIGH); // vannatimer=1; //} lcd.setCursor(16, 0); lcd.print(Day); if (hourOff-hourOn < 0) sutki=1; //     ,    =1 else sutki=0; if (EEPROM.read(114+Day)==1 && sutki==1) { rejimDay=1; lcd.print("+"); } else { rejimDay=0; lcd.print("-"); } if ((sutki==1 && rejimDay==1) && (FullMinutes >= FullMinutesTimerOn || FullMinutes <= FullMinutesTimerOff) ) { lcd.setCursor(16, 2); lcd.print("VKL"); digitalWrite(RELE_1, LOW); //   ,      } else if (sutki==1) { lcd.print(" "); digitalWrite(RELE_1, HIGH); } if (sutki == 0 && (FullMinutes >= FullMinutesTimerOn && FullMinutes <= FullMinutesTimerOff )) { lcd.setCursor(16, 2); lcd.print("VKL"); digitalWrite(RELE_1, LOW); } //    ,      else if (sutki == 0) { lcd.print(" "); digitalWrite(RELE_1, HIGH); } if (((Minute >= 0 && Minute <= minVent) && (Hour >= 9 && Hour <= 21))||(digitalRead (vanna) == HIGH)) { if (Vent==1) { lcd.setCursor(17, 1); lcd.print("VEN"); digitalWrite(RELE_2, LOW); } } if ((Minute >= 0 && Minute > minVent || digitalRead (vanna) == LOW)&&(Vent==0)) { lcd.setCursor(17, 1); lcd.print(" "); digitalWrite(RELE_2, HIGH); } if (digitalRead (vanna) == HIGH) digitalWrite(RELE_2, LOW); //          RTC.get(rtc,true); if (rejim==0) { lcd.setCursor(0, 2); lcd.print ("ojidayu komandi"); strokatimera(); digitalClockDisplay(); //    2  } if (rejim==1) { setTimerOn(); } if (rejim==2) { setTimerOff(); } if (rejim==3) { setTime(); } if (rejim==4) { setVent(); } if (rejim==5) { setVentOnOff(); } if (rejim==6) { setTimerDay1(); } if (digitalRead (button5) == HIGH) { rejim++; delay(100); if (rejim>6) rejim=0; lcd.clear(); //} } } void setTimerOn() { int hourOn= EEPROM.read(110); int minOn= EEPROM.read(111); lcd.setCursor(0, 2); lcd.print("nastroika VKL"); if (digitalRead(button3)==HIGH) //     { hourOn++; if (hourOn >=24) hourOn=0; } if (digitalRead(button2)==HIGH) //     { minOn++; if (minOn >=60) { minOn=0; hourOn++; if (hourOn >=24) hourOn=0; } } strokatimera(); digitalClockDisplay(); if ((digitalRead(button2) == HIGH)||(digitalRead(button3) == HIGH)) { EEPROM.write(110, hourOn); EEPROM.write(111, minOn); lcd.clear(); } } void setTimerOff() { int hourOff= EEPROM.read(112); int minOff= EEPROM.read(113); lcd.setCursor(0, 2); lcd.print("nastroika VIKL"); if (digitalRead(button3)==HIGH) //     { hourOff++; if (hourOff >=24) hourOff=0; } if (digitalRead(button2)==HIGH) //     { minOff++; if (minOff >=60) { minOff=0; hourOff++; if (hourOff >=24) hourOff=0; } } strokatimera(); digitalClockDisplay(); if ((digitalRead(button2) == HIGH)||(digitalRead(button3) == HIGH)) { EEPROM.write(112, hourOff); EEPROM.write(113, minOff); lcd.clear(); } } void setTime() { int Hour = rtc[2]; //  int Minute = rtc[1]; //lcd.clear(); lcd.setCursor(0, 2); lcd.print ("nastroika time"); RTC.get(rtc,true); digitalClockDisplay(); //lcd.setCursor(0, 3); //        // lcd.print(Hour); // lcd.print(":"); // lcd.print(Minute); if (digitalRead(button2)==HIGH) //     { Minute++; if (Minute >=60) { Minute=0; Hour++; if (Hour >=24) Hour=0; } } if (digitalRead(button3)==HIGH) //     { Hour++; if (Hour >=24) Hour=0; } if ((digitalRead(button2) == HIGH)||(digitalRead(button3) == HIGH)) { RTC.set(DS1307_MIN,Minute); RTC.set(DS1307_HR,Hour); lcd.clear(); } } void strokatimera() { int hourOn=EEPROM.read(110); //EEPROM.read(110) int hourOff= EEPROM.read(112);; //EEPROM.read(112) int minOn= EEPROM.read(111);; //EEPROM.read(111) int minOff= EEPROM.read(113);; //EEPROM.read(113) int minVent= EEPROM.read(114); lcd.setCursor(0, 3); //        lcd.print(hourOn); lcd.print(":"); lcd.print(minOn); lcd.print("-"); lcd.print(hourOff); lcd.print(":"); lcd.print(minOff); lcd.print(" "); lcd.print("VENT:"); lcd.print(minVent); } void setVent() { strokatimera(); int minVent= EEPROM.read(114); lcd.setCursor(0, 2); lcd.print("nastroika Vent"); if (!digitalRead(button4)) //     { minVent++; if (minVent >=60) { minVent=0; } } digitalClockDisplay(); //    2  if (digitalRead(button2) == HIGH) { EEPROM.write(114, minVent); lcd.clear(); } } void setVentOnOff() { strokatimera(); int Vent= EEPROM.read(122); lcd.setCursor(0, 2); lcd.print("Vent"); if (Vent==0) lcd.print(" Off"); if (Vent==1) lcd.print(" On"); if (!digitalRead(button4)) //       { delay(100); Vent++; if (Vent >=2) { Vent=0; } } digitalClockDisplay(); //    2  if (digitalRead(button2) == HIGH) { EEPROM.write(122, Vent); lcd.clear(); } } void setTimerDay1() { int z; //lcd.clear(); lcd.setCursor(0, 0); lcd.print ("nastroika dney"); //lcd.setCursor(0, 1); lcd.setCursor (0,3); lcd.print (EEPROM.read(115)); lcd.print (" "); lcd.print (EEPROM.read(116)); lcd.print (" "); lcd.print (EEPROM.read(117)); lcd.print (" "); lcd.print (EEPROM.read(118)); lcd.print (" "); lcd.print (EEPROM.read(119)); lcd.print (" "); lcd.print (EEPROM.read(120)); lcd.print (" "); lcd.print (EEPROM.read(121)); lcd.print (" "); //lcd.clear(); z=EEPROM.read(114+i); //     /   if (i==1) { lcd.setCursor(1, 2); lcd.print ("ponedelnik"); lcd.print (" "); lcd.print (z); } if (i==2) { lcd.setCursor(1, 2); lcd.print ("vtornik"); lcd.print (" "); lcd.print (z); } if (i==3) { lcd.setCursor(1, 2); lcd.print ("sreda"); lcd.print (" "); lcd.print (z); } if (i==4) { lcd.setCursor(1, 2); lcd.print ("chetverg"); lcd.print (" "); lcd.print (z); } if (i==5) { lcd.setCursor(1, 2); lcd.print ("pyatnica"); lcd.print (" "); lcd.print (z); } if (i==6) { lcd.setCursor(1, 2); lcd.print ("subbota"); lcd.print (" "); lcd.print (z); } if (i==7) { lcd.setCursor(1, 2); lcd.print ("voskresen'e"); lcd.print (" "); lcd.print (z); } if (digitalRead(button3)==HIGH) //   { lcd.clear(); i++; delay(150); if (i>7) {i=1;} } if (digitalRead(button2)==HIGH) { delay(150); z=!z; if (z!= EEPROM.read(114+i)) { EEPROM.write(114+i,z); } } //EEPROM.write(115, 0);// //EEPROM.write(116, 0);// //EEPROM.write(117, 1);// //EEPROM.write(118, 0);// //EEPROM.write(119, 1);// //EEPROM.write(120, 1);// //EEPROM.write(121, 0);// //z=EEPROM.read(114+i); }
      
      








All Articles