3866| 1
|
[高级教程] 当掌控遇上Blynk(5)——远程声音光线检测 |
本帖最后由 peter3 于 2019-1-6 14:11 编辑 [mw_shl_code=python,true]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 [/mw_shl_code] |
© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed