0

I am developing a project using pico w.

My objective is to add a timer to it. How can I do it ?

I want to create a timer like this:

  • When it is 04:00 in the U.T.C. time zone, the kitchen lamp will be turned on."

I want to add something like this. What can I do?

import urequests as requests from dfplayer import Player import time 

music = Player(pin_TX=Pin(8), pin_RX=Pin(9))


# This is an example Anvil Uplink script for the Pico W.
# See https://anvil.works/pico for more information dfplayer_RX = Pin(4, Pin.OUT) dfplayer_TX = Pin(5, Pin.OUT)

UPLINK_KEY = "xxxxxxxxxxx"
# We use the LED to indicate server calls and responses. in1 = Pin(14, Pin.OUT) in2 = Pin(15, Pin.OUT) led3 = Pin(16, Pin.OUT) led4 = Pin(17,
Pin.OUT)

in1.value(1) in2.value(1) led3.value(0) led4.value(0)




@anvil.pico.callable(is_async=True) async def mutfak(n):
    for i in range(3):
        in1.toggle()
        sleep(1)
        await a.sleep_ms(5)
        return n * 2
     @anvil.pico.callable(is_async=True) async def kombi(x):
    for i in range(5):
        in2.toggle()
      
        sleep(1)
        await a.sleep_ms(5)
        return x * 2
     @anvil.pico.callable(is_async=True) async def diskapikontrol(y):
    for i in range (5):
        led3.toggle()
      
        sleep(1)
        await a.sleep_ms(5)
        return y * 2
     @anvil.pico.callable(is_async=True) async def salonperde(z):
    for i in range (5):
        led4.toggle()
        
        sleep(1)
        await a.sleep_ms(5)
        return z * 2

@anvil.pico.callable(is_async=True) async def mutfaklambasiniac():
    print("MUTFAK LAMBASI AÇILDI")
    music.play(4)
    sleep(2)
    
     @anvil.pico.callable(is_async=True) async def mutfaklambasinikapat():
    print("MUTFAK LAMBASI KAPATILDI")
    music.play(3)
    sleep(2)

@anvil.pico.callable(is_async=True) async def kombiac():
    print("KOMBİ AÇILDI")
    music.play(6)
    sleep(2)

@anvil.pico.callable(is_async=True) async def kombikapat():
    print("KOMBİ KAPATILDI")
    music.play(5)
    sleep(2)

@anvil.pico.callable(is_async=True) async def diskapiac():
    print("DIŞ KAPI AÇILDI")
    music.play(8)
    sleep(2)

@anvil.pico.callable(is_async=True) async def diskapikapat():
    print("DIŞ KAPI KAPATILDI")
    music.play(7)
    sleep(2)

@anvil.pico.callable(is_async=True) async def salonperdeac():
    print("SALON PERDESİ AÇILDI")
    music.play(2)
    sleep(1)

@anvil.pico.callable(is_async=True) async def salonperdekapat():
    print("SALON PERDESİ KAPATILDI")
    music.play(1)
    sleep(2)

anvil.pico.connect(UPLINK_KEY)

I tried to add the code block below but got an error. CODE BLOCK

print(date_time)

def set_alarm():  global set_hour     global set_minute   global
set_second    global hour     global minute   global second

  while text_box_1_pressed_enter.text():      set_hour += value
      set_minute +=value      set_second += value         utime.sleep(0.1)
      set_hour = set_hour%24
              set_minute = set_minute%60      set_second = set_second%60      hour = str(set_hour)        minute = str(set_minute)        second =
str(set_second)   

  while text_box_2_pressed_enter.text():      set_hour += value
      set_minute += value         set_second += value         utime.sleep(0.1)
      set_hour = set_hour%24      set_minute = set_minute%60      set_second =
set_second%60         hour = str(set_hour)        minute = str(set_minute)
      second = str(set_second)

  while text_box_3_pressed_enter.text():      set_hour += value
      set_minute += value         set_second += value         utime.sleep(0.1)
      set_hour = set_hour%24      set_minute = set_minute%60      set_second =
set_second%60         hour = str(set_hour)        minute = str(set_minute)
      second = str(set_second)

  while text_box_4    _pressed_enter.text():      set_hour += value
      set_minute += value         set_second += value         utime.sleep(0.1)
      set_hour = set_hour%24      set_minute = set_minute%60      set_second =
set_second%60         hour = str(set_hour)        minute = str(set_minute)
      second = str(set_second)


while True:     (Y,M,D,day,hr,m,s)=ds.date_time()
    if s < 10:
        s = "0" + str(s)
    if m < 10:
        m = "0" + str(m)
    if hr < 10:
        hr = "0" + str(hr)
    if D < 10:
        D = "0" + str(D)
    if M < 10:
        M = "0" + str(M)

    check_alarm(set_hour, set_minute, set_second)

0 Answers0