소스 검색

Local time

master
Pete Shadbolt 5 년 전
부모
커밋
e498844542
1개의 변경된 파일43개의 추가작업 그리고 7개의 파일을 삭제
  1. +43
    -7
      xmas.py

+ 43
- 7
xmas.py 파일 보기

@@ -1,10 +1,46 @@
from time import sleep
import schedule
import time
import datetime
import pifacedigitalio as p

p.init()

while(True):
p.digital_write(0,1) #turn on
sleep(3)
p.digital_write(0,0) #turn off
sleep(5)
def timestamp():
return datetime.datetime.now()


def turn_on():
""" Turn on the christmas tree """
print("{} ON".format(timestamp()))
p.digital_write(0, 1)


def turn_off():
""" Turn off the christmas tree """
print("{} OFF".format(timestamp()))
p.digital_write(0, 0)


def check_connectivity():
""" Flick the switch """
for i in range(10):
turn_on()
time.sleep(.3)
turn_off()
time.sleep(.3)


if __name__ == "__main__":
# Connect to PiFace
p.init()

# Check connectivity
check_connectivity()

# Set up the schedule
schedule.every().day.at("17:00").do(turn_on)
schedule.every().day.at("23:59").do(turn_off)

# Run the event loop
while(True):
schedule.run_pending()
time.sleep(1)

불러오는 중...
취소
저장