import blynklib as blynklib
from Pin
import uping
import network
import time
BLYNK_TEMPLATE_ID = "TMPL20CVgxhr6"
BLYNK_TEMPLATE_NAME = "Quickstart Template"
BLYNK_AUTH = "Q2IGLUosI8aQtmGDNCeWsxTSYm9MVsu3"
print("Connecting to WiFi", end="")
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect("Wokwi-GUEST", "")
while not wlan.isconnected():
print(".", end="")
time.sleep(0.1)
print(" Connected!")
print(wlan.ifconfig())
time.sleep(1)
print("Connecting to Blynk server...")
try:
blynk = blynklib.Blynk(BLYNK_AUTH)
print("Blynk Connected Successfuly")
except Error as err:
print(err)
@blynk.handle_event('write V4')
def write_virtual_pin_handler(pin, value):
if value == ['1']:
print(WRITE_EVENT_PRINT_MSG.format(pin, value))
print('LED allumee')
GPIO.output(ledPin, GPIO.HIGH)
else:
print(WRITE_EVENT_PRINT_MSG.format(pin, value))
print('LED eteinte')
GPIO.output(ledPin, GPIO.LOW)
while True:
blynk.run()