peter3 发表于 2019-1-5 19:50:31

当掌控遇上Blynk(5)——远程声音光线检测

本帖最后由 peter3 于 2019-1-6 14:11 编辑










import network,BlynkLib,time,musicfrom mpython import *
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
if not wlan.isconnected():
print('connecting to network...')
wlan.connect('Maker Space', '20140811')   #wifi信息
while not wlan.isconnected():
    pass
print('network config:', wlan.ifconfig())#输出wifi连接信息
BLYNK_AUTH = 'bf0c2b95ede846c5bbb79fb3bb52b1a7'#Blynk授权码
blynk = BlynkLib.Blynk(BLYNK_AUTH)# 初始化Blynk连接
@blynk.VIRTUAL_READ(0)#声音值
def v0_read_handler():
    blynk.virtual_write(0, sound.read())#发送声音值到V0

@blynk.VIRTUAL_READ(1)#光线值
def v1_read_handler():
    blynk.virtual_write(1, light.read())#发送光线值到V1
while True:
      blynk.run()#一直运行blynk
      pass


https://v.qq.com/x/page/d0823pg7aqy.html

rzyzzxw 发表于 2019-1-8 20:41:04


学习完成,慢慢消化。:victory:
页: [1]
查看完整版本: 当掌控遇上Blynk(5)——远程声音光线检测