Skocz do zawartości

Podlewanie używając RTC


Vasiva

Pomocna odpowiedź

Witam wszystkich!

To mój pierwszy post na forum, jestem bardzo początkujący z arduino więc byłbym wdzięczny za nie wyśmiewanie.

Robię system nawadniający z użyciem rtc ds3231 i modułem przekaźnikowym i chciałbym żeby przekaźnik uruchamiał się co dwa dni o godzinie 18 i nie wiem czy program który zrobiłem będzie działał i byłbym wdzięczny gdyby ktoś mógł go sprawdzić. Chętnie przyjmę każde rady

// DS3231_Serial_Easy
// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
// web: http://www.RinkyDinkElectronics.com/
//
// A quick demo of how to use my DS3231-library to 
// quickly send time and date information over a serial link
//
// To use the hardware I2C (TWI) interface of the Arduino you must connect
// the pins as follows:
//
// Arduino Uno/2009:
// ----------------------
// DS3231:  SDA pin   -> Arduino Analog 4 or the dedicated SDA pin
//          SCL pin   -> Arduino Analog 5 or the dedicated SCL pin
//
// Arduino Leonardo:
// ----------------------
// DS3231:  SDA pin   -> Arduino Digital 2 or the dedicated SDA pin
//          SCL pin   -> Arduino Digital 3 or the dedicated SCL pin
//
// Arduino Mega:
// ----------------------
// DS3231:  SDA pin   -> Arduino Digital 20 (SDA) or the dedicated SDA pin
//          SCL pin   -> Arduino Digital 21 (SCL) or the dedicated SCL pin
//
// Arduino Due:
// ----------------------
// DS3231:  SDA pin   -> Arduino Digital 20 (SDA) or the dedicated SDA1 (Digital 70) pin
//          SCL pin   -> Arduino Digital 21 (SCL) or the dedicated SCL1 (Digital 71) pin
//
// The internal pull-up resistors will be activated when using the 
// hardware I2C interfaces.
//
// You can connect the DS3231 to any available pin but if you use any
// other than what is described above the library will fall back to
// a software-based, TWI-like protocol which will require exclusive access 
// to the pins used, and you will also have to use appropriate, external
// pull-up resistors on the data and clock signals.
//

#include <DS3231.h>

// Init the DS3231 using the hardware interface
DS3231  rtc(SDA, SCL);
  int  godzina = rtc.getTime().hour;
  int  minuta = rtc.getTime().min;
  int  sekunda = rtc.getTime().sec;
  int  data = rtc.getTime().date;
  int  miesiac = rtc.getTime().mon;
  int a = 8;
  int b = 5;
void setup()
{
  // Setup Serial connection
  Serial.begin(115200);
  // Uncomment the next line if you are using an Arduino Leonardo
  //while (!Serial) {}
  
  // Initialize the rtc object
  rtc.begin();
  
  // The following lines can be uncommented to set the date and time

  pinMode(2, OUTPUT);
  digitalWrite(2, HIGH);

}

void loop()
{
  if ((godzina == 17) && (minuta == 00) && (sekunda == 00) && (data == a) && (miesiac == b)) {

  digitalWrite(2,LOW);
  delay (5000);
  digitalWrite(2, HIGH);
  if (a == 30) {
    int b = 6;
    int a = 1;
  }
  a = a + 2;
  }
  // Dzień tygodnia
  Serial.print(rtc.getDOWStr());
  Serial.print(" ");
  
  // Data
  Serial.print(rtc.getDateStr());
  Serial.print(" -- ");

  // Czas
  Serial.println(rtc.getTimeStr());


  delay (1000);
}

 

Edytowano przez Vasiva
Link do komentarza
Share on other sites

@Vasiva witam na forum! 🙂 

3 godziny temu, Vasiva napisał:

więc byłbym wdzięczny za nie wyśmiewanie.

Bez obaw, ale byłoby dobrze gdybyś wrzucił kod programu w treść stosując ramkę na kod - masz to w edytorze wiadomości tuż obok 'italika'.

Link do komentarza
Share on other sites

Bądź aktywny - zaloguj się lub utwórz konto!

Tylko zarejestrowani użytkownicy mogą komentować zawartość tej strony

Utwórz konto w ~20 sekund!

Zarejestruj nowe konto, to proste!

Zarejestruj się »

Zaloguj się

Posiadasz własne konto? Użyj go!

Zaloguj się »
×
×
  • Utwórz nowe...

Ważne informacje

Ta strona używa ciasteczek (cookies), dzięki którym może działać lepiej. Więcej na ten temat znajdziesz w Polityce Prywatności.