# pico board WiFi 버전 : 특성 변경 필요 "attrs": *********** { "cyw43": "1" } ********************
from machine import Pin
import time, network, random
import BlynkLib
#wifi 연결
ssid = '************'
password= '**********'
wifi = network.WLAN(network.STA_IF)
if not wifi.isconnected():
print("Connecting to WiFi...")
wifi.active(True)
wifi.connect( ssid, password)
while not wifi.isconnected():
print(".", end="_")
time.sleep(1)
print('\nWifi connected, IP:', wifi.ifconfig()[0])
red = Pin( 22, Pin.OUT)
green = Pin( 20, Pin.OUT)
blue = Pin( 16, Pin.OUT)
# Blynk 연결
BLYNK_AUTH = "qUGxnH5hH1ZvQ-jq_fOElamtArV3_ReT"
blynk = BlynkLib.Blynk(BLYNK_AUTH, insecure=True)
@blynk.on("connected")
def connected(ping):
print('Blynk Server is Connected, ready. Ping:', ping, 'ms')
# Red LED
@blynk.on("V11")
def vpin0(value):
if value[0] == '1':
red.on()
status = 'ON'
else:
red.off()
status = 'OFF'
print(f"Red_Led is {status}")
# Blue LED
@blynk.on("V12")
def vpin3(value):
if value[0] == '1':
green.on()
status = 'ON'
else:
green.off()
status = 'OFF'
print(f"Green_Led is {status}")
# Blue LED
@blynk.on("V13")
def vpin3(value):
if value[0] == '1':
blue.on()
status = 'ON'
else:
blue.off()
status = 'OFF'
print(f"Blue_Led is {status}")
# Main program
while True:
blynk.run()
time.sleep(0.1)