Created
August 12, 2021 16:54
-
-
Save ypelletier/1fb901fec5b1979a316d53b1b7309e70 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Utilisation d'un module RTC DS3231 avec | |
le Raspberry Pi Pico | |
Réglage de la date et de l'heure. | |
Plus d'infos: | |
https://electroniqueamateur.blogspot.com/2021/08/horloge-temps-reel-ds3231-et-raspberry.html | |
''' | |
import urtc | |
from machine import I2C, Pin | |
i2c = I2C(0,scl=Pin(9), sda=Pin(8)) | |
rtc = urtc.DS3231(i2c) | |
print("Reglage de la date et de l'heure") | |
annee = int(input ("Annee (4 chiffres): ")) | |
mois = int(input ("Mois (1-12): ")) | |
jour = int(input("Jour (1-31): ")) | |
heure = int(input("Heure (0-23): ")) | |
minute = int(input("Minute (0-59): ")) | |
seconde = int(input("Seconde (0-59): ")) | |
maintenant = urtc.datetime_tuple(year=annee, month=mois, day=jour, hour=heure, minute=minute, second=seconde) | |
rtc.datetime(maintenant) | |
print ("La date et l'heure ont été modifiées") | |
print(maintenant) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment