I don't know how to do the code for an rtc controlling a relay I'm doing a project for my brother witch is an automatic watering thing,
it's all working fine but I just don't know how to repeat the code to make the relay say come on for 5min at 0900 than 5min at 1200 and also 5min at 1700.
how do I do this, I'm not very good at this so I need clear instructions or someone to write it.
pls help.
thank you, James.

here is the code I need to be repeated to meet what I need done, basically I just need the relay to trigger every 4h for 5min. its on an rtc on an Arduino UNO.

#include &lt;DS3231.h&gt;

int Relay = 4;

DS3231  rtc(SDA, SCL);
Time t;

const int OnHour = 19; //SET TIME TO ON RELAY (24 HOUR FORMAT)
const int OnMin = 55;
const int OffHour = 19; //SET TIME TO OFF RELAY
const int OffMin = 56;


void setup() {
  Serial.begin(115200);
  rtc.begin();
  pinMode(Relay, OUTPUT);
  digitalWrite(Relay, LOW);
}

void loop() {
  t = rtc.getTime();
  Serial.print(t.hour);
  Serial.print(" hour(s), ");
  Serial.print(t.min);
  Serial.print(" minute(s)");
  Serial.println(" ");
  delay (1000);

  if(t.hour == OnHour &amp;&amp; t.min == OnMin){
    digitalWrite(Relay,HIGH);
    Serial.println("LIGHT ON");
    }

    else if(t.hour == OffHour &amp;&amp; t.min == OffMin){
      digitalWrite(Relay,LOW);
      Serial.println("LIGHT OFF");
    }
}
You will most likely find nobody here, who will write the code for you, since this is not a free code writing service. But I will suggest a good way.


  I just need the relay to trigger every 4h for 5min


The phrase "every x hours" screams for using the modulo operator %. Modulo gives you the rest value of an integer division. See these values:

0 % 4 = 0
1 % 4 = 1
2 % 4 = 2
3 % 4 = 3
4 % 4 = 0
5 % 4 = 1
...
7 % 4 = 3
8 % 4 = 0


You see, the modulo 4 operation gives you zero every 4 hours starting with midnight. So make an if statement based on that

if(hour % 4 == 0 &amp;&amp; min == 0)


to switch on and

if(hour % 4 == 0 &amp;&amp; min == 5)


to switch off. Just change your code in this way and you are done.