turning on and off growth light LED for a certain duration

Hi i am trying to write a code to turn on the growth light LED for 14 hours and then turn off for 10 hours. Can anyone please tell me how to do it ? also if possible, if there is any coding example for me to understand better it will be good

also the coding is to be integrated with my future PH level coding so I cannot use the delay() function to delay it for 14 hours

Many thanks

Have a look at the blink without delay example in the IDE.

Hi thanks for your reply. the suggestion you given me works but i have a question, when i integrate the code into my future PH code how do I make sure that it wont clash

Also how do i make this code turn on the LED when it is first executed?

toomer:
Also how do i make this code turn on the LED when it is first executed?

I don't see any code.

const int ledPin = 1 ;// the number of the LED pin


int ledState = LOW;             // ledState used to set the LED


unsigned long previousMillis = 0;        // will store last time LED was updated


const long interval = 50400000;           // interval at which to blink (milliseconds)

void setup() {
 
  pinMode(1, OUTPUT);
}

void loop() {
 
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    // save the last time the LED blink
    previousMillis = currentMillis;

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW) {
      ledState = HIGH;
    } else {
      ledState = LOW;
    }

    // set the LED with the ledState of the variable:
    digitalWrite(1, ledState);
  }
}

here is the code

You could set and write the desired LED state as soon as you have set the LEDpin (pin 1, poor choice IMO) to be an output.

toomer:
here is the code

Looks like the LED will be on for 14 hours and off for 14 hours.

50400000ms / 1000ms / 60s / 60m = 14 hours

It's the only timer used. You need to create another timer for 10 hours, do the digitalWrite(pin, HIGH) in the setup. In the loop use 10hr timer to write LOW(LED on for 10hrs then turned off) and use 14hr timer to write HIGH(LED off for 10hrs then turned on).