Code: Alles auswählen
import machine
import utime
from machine import Pin
from time import sleep
Lights = Pin(19, machine.Pin.OUT)
Water = machine.Pin(18, machine.Pin.OUT)
Day = 0
Time = 0
def WateringDWS():
Water.value(1)
utime.sleep(10)
Water.value(0)
def Lights_on():
Lights.value(0)
def Lights_off():
Lights.value(1)
def Wait_hours(Hours):
global hours_to_wait
hours_to_wait = 0
while hours_to_wait <= Hours:
hours_to_wait += 1
utime.sleep(3600)
global Time
Time += 1
Lights_on()
Wait_hours(11) #7 to 18 O Clock
Lights_off()
Wait_hours(6)
while True:
Day += 1
Time = 0
Wait_hours(4) #0 to 4 O Clock
Lights_on() #Works like a Switch
#if Day % 1 == 0:
Wait_hours(18) #7 to 22 O Clock
Lights_off()
Wait_hours(2) #22 to 24 O Clock