Home
Features
_Multi DropDown
__DropDown 1
__DropDown 2
__DropDown 3
_ShortCodes
_SiteMap
_Error Page
Mega Menu
Documentation
_Web Documentation
_Video Documentation
Privacy Policy
Daftar Isi
Beranda
Micropython NTP Clock
Micropython NTP Clock
Mei 04, 2022
Micropython NTC Clock
import network, ntptime from machine import RTC import time import tm1637 from machine import Pin tm = tm1637.TM1637(clk=Pin(5), dio=Pin(4)) SSID="AFFAN" PWD="66666666" # dictionary that maps string date names to indexes in the RTC's datetime tuple DATETIME_ELEMENTS = { "year": 0, "month": 1, "day": 2, "day_of_week": 3, "hour": 4, "minute": 5, "second": 6, "millisecond": 7 } def connect_to_wifi(wlan, ssid, password): if not wlan.isconnected(): print("Connecting to network...") wlan.connect(ssid, password) while not wlan.isconnected(): pass # set an element of the RTC's datetime to a different value def set_datetime_element(rtc, datetime_element, value): date = list(rtc.datetime()) date[DATETIME_ELEMENTS[datetime_element]] = value rtc.datetime(date) tm.show('cont') #tm.write([0b00111001, 0b00111111, 0b00111111, 0b00111000]) wlan = network.WLAN(network.STA_IF) wlan.active(True) connect_to_wifi(wlan, SSID, PWD) rtc = RTC() ntptime.settime() print(rtc.datetime()) hr=rtc.datetime()[4]+7 if (hr>=24): hr=hr-24 mn=rtc.datetime()[5] sc=rtc.datetime()[6] print(hr) print(mn) tdelay=0.9953 while True: tm.numbers(hr, mn) time.sleep(tdelay) tm.write([0, 0, 0, 0]) sc=sc+1 if sc>=59: mn=mn+1 sc=0 if mn>=59: hr=hr+1 sc=0 mn=0 # connect_to_wifi(wlan, SSID, PWD) # ntptime.settime() # hr=rtc.datetime()[4]+7 # if (hr>=24): # hr=hr-24 # mn=rtc.datetime()[5] # sc=rtc.datetime()[6] # if hr>=24: # hr=0 # mn=0 # sc=0 # ntptime.settime() # hr=rtc.datetime()[4]+7 # if (hr>=24): # hr=hr-24 # mn=rtc.datetime()[5] # sc=rtc.datetime()[6]
Social Plugin
ARTIKEL
3/recent/post-list
Facebook
Subscribe Us