-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathS18_RTC.py
More file actions
33 lines (27 loc) · 931 Bytes
/
S18_RTC.py
File metadata and controls
33 lines (27 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File: main.py
# Author: Armstrong Subero
# Platform: Raspberry Pi Pico (RP2040) with MicroPython
# Program: S18_RTC
# Interpreter: MicroPython (latest version)
# Program Version: 1.0
#
# Program Description: This program allows the Raspberry Pi Pico to
# use the onboard RTC
#
# Hardware Description: The PICO is connected to PC via USB
#
# Created: August 23rd, 2024, 12:04 AM
# Last Updated: August 23rd, 2024, 12:04 AM
from machine import RTC
import utime
# Initialize the RTC (Real-Time Clock)
rtc = RTC()
# Set a specific date and time: (year, month, day, weekday, hours, minutes, seconds, subseconds)
rtc.datetime((2017, 8, 23, 2, 12, 48, 0, 0))
while True:
# Get the current date and time from the RTC
current_time = rtc.datetime()
# Print the current date and time
print(current_time)
# Sleep for 1 second before repeating
utime.sleep(1)