I would like to run my a function within my python program when the time is 7am. Almost like a when function when time == time:
I don't want to use cron because I want this to be internal function not executing the whole script
Here is my python script I have created:
#sprinkler.py file for sprinkler system
#this is the main file for the sprinklerOS
#functions to import for our test_run.py file
import RPi.GPIO as GPIO
import time
import argparse
import sys
import datetime
#how many zones the user/YOU have set up
zone_count = 10
#gpio pins on the raspberry pi for sprinkler system
pin = [12,7,16,11,18,13,22,15,32,29]
#set mode to board meaning the pin number on pi (1-40) instead of gpio number
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
#setting up all of the lights or relays as outputs(in a while loop)
for a in range(10):
GPIO.setup(pin[a],GPIO.OUT)
GPIO.output(pin[a], GPIO.LOW)
def run_sprinklers():
for b in range(zone_count):
run_time = 5
GPIO.output(pin[b], GPIO.HIGH)
time.sleep(run_time)
GPIO.output(pin[b], GPIO.LOW)
time.sleep(1)
I want to run_sprinklers() when the time is 7am Thank you in advanced