Create set_clock.py
This commit is contained in:
parent
484c3a4ddb
commit
d504f16cff
1 changed files with 31 additions and 0 deletions
31
CircuitPython_Simple_Wordclock/set_clock.py
Normal file
31
CircuitPython_Simple_Wordclock/set_clock.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# Write the time for the Adafruit DS3231 real-time clock.
|
||||
# Limor Fried/Mike Barela for Adafruit Industries
|
||||
|
||||
import time
|
||||
import board
|
||||
import busio as io
|
||||
import digitalio
|
||||
import adafruit_ds3231
|
||||
|
||||
i2c = io.I2C(board.SCL, board.SDA)
|
||||
|
||||
# Create the RTC instance:
|
||||
rtc = adafruit_ds3231.DS3231(i2c)
|
||||
|
||||
LED13 = digitalio.DigitalInOut(board.D13)
|
||||
LED13.direction = digitalio.Direction.OUTPUT
|
||||
|
||||
# pylint: disable-msg=bad-whitespace
|
||||
# pylint: disable-msg=using-constant-test
|
||||
if True:
|
||||
# year, mon, date, hour, min, sec, wday, yday, isdst
|
||||
t = time.struct_time((2019, 7, 10, 17, 00, 0, 0, -1, -1))
|
||||
# you must set year, mon, date, hour, min, sec and weekday
|
||||
# yearday is not supported
|
||||
# isdst can be set but we don't do anything with it at this time
|
||||
print("Setting time to:", t) # uncomment for debugging
|
||||
rtc.datetime = t
|
||||
print("Done!")
|
||||
LED13.value = True
|
||||
# pylint: enable-msg=using-constant-test
|
||||
# pylint: enable-msg=bad-whitespace
|
||||
Loading…
Reference in a new issue