Skip to content

Commit 0a50991

Browse files
authored
Merge pull request #760 from adafruit/TheKitty-patch-95
Create set_clock.py for Word Clock
2 parents 484c3a4 + d504f16 commit 0a50991

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Write the time for the Adafruit DS3231 real-time clock.
2+
# Limor Fried/Mike Barela for Adafruit Industries
3+
4+
import time
5+
import board
6+
import busio as io
7+
import digitalio
8+
import adafruit_ds3231
9+
10+
i2c = io.I2C(board.SCL, board.SDA)
11+
12+
# Create the RTC instance:
13+
rtc = adafruit_ds3231.DS3231(i2c)
14+
15+
LED13 = digitalio.DigitalInOut(board.D13)
16+
LED13.direction = digitalio.Direction.OUTPUT
17+
18+
# pylint: disable-msg=bad-whitespace
19+
# pylint: disable-msg=using-constant-test
20+
if True:
21+
# year, mon, date, hour, min, sec, wday, yday, isdst
22+
t = time.struct_time((2019, 7, 10, 17, 00, 0, 0, -1, -1))
23+
# you must set year, mon, date, hour, min, sec and weekday
24+
# yearday is not supported
25+
# isdst can be set but we don't do anything with it at this time
26+
print("Setting time to:", t) # uncomment for debugging
27+
rtc.datetime = t
28+
print("Done!")
29+
LED13.value = True
30+
# pylint: enable-msg=using-constant-test
31+
# pylint: enable-msg=bad-whitespace

0 commit comments

Comments
 (0)