I looked everywhere and it look like Chinese for me..
I can't figure how to get a simple time event as following:
if time is between x and y
this happen ..
I can't figure how to get the value out of the time parameter to write my code..
Can anyone help me out with that ?
I need a simple code who would make A=1 if the current time is between 0700 and 2100...
As simple as It sound I can't seem to figure it out..
Chinese looks fine if you know Chinese.
I have no idea what you are talking about as you haven't posted any code
I rode those multiple time.. here a short script to explain my issue:
import time
time.ctime()
time.strftime('%l:%M%p %Z on %b %d, %Y')
while time.strftime('%l')>7 and time.strftime('%l')<21:
#event happen here..
import time
time.ctime()
time.strftime("%a, %d %b %Y %H:%M:%S")
h = int(time.strftime('%H'))
if h > 7 and h<21:
print("f")
prints "f" if the time is between 0700 and 2100. Elsewise, instead of print("f"), you can make it A=1
Awesome, il give a try. THANK !
Work great ! thank.
complete code if you need some light for your plant:
#A2.1
import RPi.GPIO as GPIO
import datetime
import time
time.ctime()
time.strftime("%a, %d %b %Y %H:%M:%S")
h = int(time.strftime('%H'))
light = 21
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
if h>=7 and h<21:
GPIO.setup(light, GPIO.OUT)
GPIO.output(light, GPIO.LOW)
now = datetime.datetime.now()
path = '/media/pi/34BF-2414/log.txt'
log = open(path,'a')
log.write(now.strftime('\n' + "%Y-%m-%d %H:%M"))
log.write(' Main light ON')
log.close()
else:
GPIO.output(light, GPIO.HIGH)
now = datetime.datetime.now()
path = '/media/pi/34BF-2414/log.txt'
log = open(path,'a')
log.write(now.strftime('\n' + "%Y-%m-%d %H:%M"))
log.write(' Main light OFF')
log.close()