import esp, network, time
from machine import Pin, Timer

p0 = Pin(0, Pin.OUT)    # create output pin on GPIO0
# p0.on()                 # set pin to "on" (high) level
p0.value(0)
# p0.off() 

print("Connecting to WiFi", end="")
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
sta_if.connect('Wokwi-GUEST', '')
while not sta_if.isconnected():
  print(".", end="")
  time.sleep(0.1)
print(" Connected!")


timer=Timer(-1)
timer.init(period=1000, mode=Timer.PERIODIC, callback=lambda t:p0.value(not p0.value()))   #initializing the timer


# while True:
    # print("Terkoneksi", end="")