MicroPython动手做(30)——物联网之Blynk-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

楼主: eagler8

MicroPython动手做(30)——物联网之Blynk

[复制链接]
 楼主| 发表于 2020-6-8 15:00 | 显示全部楼层
07.jpg
 楼主| 发表于 2020-6-8 15:01 | 显示全部楼层
08.jpg
 楼主| 发表于 2020-6-8 20:00 | 显示全部楼层

2、尝试简单打印Blynk的v值

设置APP

10.jpg


 楼主| 发表于 2020-6-8 20:02 | 显示全部楼层
#MicroPython动手做(30)——物联网之Blynk
#尝试简单打印Blynk的v值

[mw_shl_code=arduino,true]#MicroPython动手做(30)——物联网之Blynk
#尝试简单打印Blynk的v值

from mpython import *

import network

my_wifi = wifi()

my_wifi.connectWiFi('zh', 'zy1567')

import blynklib

blynk = blynklib.Blynk('N14sXx7xQ-rXQF4_gKIFjEQqCC_LzybL', server='116.62.49.166', port=8080)

@blynk.handle_event("connect")
def connect_handler():
    print('Blynk connected')

@blynk.handle_event("disconnect")
def connect_handler():
    print('Blynk disconnected')

@blynk.handle_event('write V0')
def write_virtual_pin_handler(pin, _value):
    global v
    for i in range(0, len(_value)):
        try: _value = eval(_value)
        except: pass
    if len(_value) == 1: _value = _value[0]
    print(v)
while True:
    blynk.run()[/mw_shl_code]

 楼主| 发表于 2020-6-8 20:06 | 显示全部楼层
mPython 实验图形编程


11.jpg
 楼主| 发表于 2020-6-8 20:10 | 显示全部楼层
串口打印输出

12.jpg
 楼主| 发表于 2020-6-8 20:59 | 显示全部楼层

3、远程开关控制板载RGB灯

连接服务器IP:116.62.49.166  端口: 8080


设置APP组件

13.jpg


 楼主| 发表于 2020-6-8 21:07 | 显示全部楼层
#MicroPython动手做(30)——物联网之Blynk
#远程开关控制板载RGB灯

[mw_shl_code=arduino,true]#MicroPython动手做(30)——物联网之Blynk
#远程开关控制板载RGB灯

from mpython import *
import network
import blynklib
import time
import music

my_wifi = wifi()

my_wifi.connectWiFi("zh", "zy1567")

blynk = blynklib.Blynk("N14sXx7xQ-rXQF4_gKIFjEQqCC_LzybL", server="116.62.49.166", port=8080)

@blynk.handle_event("connect")
def connect_handler():
    print('Blynk connected')

@blynk.handle_event("disconnect")
def connect_handler():
    print('Blynk disconnected')

@blynk.handle_event('write V1')
def write_virtual_pin_handler(pin, _value):
    global i
    for i in range(0, len(_value)):
        try: _value = eval(_value)
        except: pass
    if len(_value) == 1: _value = _value[0]
    rgb.fill((int(153), int(0), int(0)))
    rgb.write()
    time.sleep_ms(1)
    music.play('G5:1')

@blynk.handle_event('write V0')
def write_virtual_pin_handler(pin, _value):
    global i
    for i in range(0, len(_value)):
        try: _value = eval(_value)
        except: pass
    if len(_value) == 1: _value = _value[0]
    rgb.fill( (0, 0, 0) )
    rgb.write()
    time.sleep_ms(1)
    music.play('E5:1')


oled.fill(0)
oled.DispChar("        网络已经连接", 0, 16, 1)
oled.show()
rgb[1] = (int(0), int(102), int(0))
rgb.write()
time.sleep_ms(1)
music.play('C5:1')
while True:
    blynk.run()[/mw_shl_code]
 楼主| 发表于 2020-6-8 21:13 | 显示全部楼层
mPython X 实验图形编程

14.jpg
 楼主| 发表于 2020-6-8 21:23 | 显示全部楼层
#MicroPython动手做(30)——物联网之Blynk
#远程开关控制板载RGB灯(实验视频)

https://v.youku.com/v_show/id_XN ... oneSokuUgc_1.dtitle

15.jpg

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-12-28 01:18 , Processed in 0.079874 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表