#MicroPython动手做(30)——物联网之Blynk
#Blynk远程控制七彩灯RGB
#MicroPython动手做(30)——物联网之Blynk
#Blynk远程控制七彩灯RGB
from mpython import *
import network
import music
import blynklib
import time
my_wifi = wifi()
my_wifi.connectWiFi("zh", "zy1567")
blynk = blynklib.Blynk("CO1NhMoRAYxP3p3hBjvsqrrHmIoYzM0e", 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 my_list
for i in range(0, len(_value)):
try: _value = eval(_value)
except: pass
if len(_value) == 1: _value = _value
my_list = _value
rgb.fill( (int(my_list), int(my_list), int(my_list)) )
rgb.write()
time.sleep_ms(1)
music.play('G5:1')
oled.fill(0)
oled.DispChar(" 远程控制七彩灯RGB", 0, 16, 1)
oled.show()
rgb = (int(0), int(102), int(0))
rgb.write()
time.sleep_ms(1)
while True:
blynk.run()
mPython X 实验图形编程
#MicroPython动手做(30)——物联网之Blynk
#Blynk远程控制七彩灯RGB
https://v.youku.com/v_show/id_XNDcwNTIxNjAzNg==.html
https://v.youku.com/v_show/id_XNDcwNTIxNjAzNg==.html
5、远程网络八音盒电子琴
设置的APP控制面板元素为
#MicroPython动手做(30)——物联网之Blynk
#远程网络八音盒电子琴
#MicroPython动手做(30)——物联网之Blynk
#远程网络八音盒电子琴
from mpython import *
import network
import blynklib
import time
import music
my_wifi = wifi()
my_wifi.connectWiFi("zh", "zy1567")
blynk = blynklib.Blynk("8d52fd7ed2844892a843158e127ed3f2", server="blynk.mpython.cn", 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 my_list
for i in range(0, len(_value)):
try: _value = eval(_value)
except: pass
if len(_value) == 1: _value = _value
music.play('C3:2')
@blynk.handle_event('write V2')
def write_virtual_pin_handler(pin, _value):
global my_list
for i in range(0, len(_value)):
try: _value = eval(_value)
except: pass
if len(_value) == 1: _value = _value
music.play('D3:2')
@blynk.handle_event('write V3')
def write_virtual_pin_handler(pin, _value):
global my_list
for i in range(0, len(_value)):
try: _value = eval(_value)
except: pass
if len(_value) == 1: _value = _value
music.play('E3:2')
@blynk.handle_event('write V4')
def write_virtual_pin_handler(pin, _value):
global my_list
for i in range(0, len(_value)):
try: _value = eval(_value)
except: pass
if len(_value) == 1: _value = _value
music.play('F3:2')
@blynk.handle_event('write V5')
def write_virtual_pin_handler(pin, _value):
global my_list
for i in range(0, len(_value)):
try: _value = eval(_value)
except: pass
if len(_value) == 1: _value = _value
music.play('G3:2')
@blynk.handle_event('write V6')
def write_virtual_pin_handler(pin, _value):
global my_list
for i in range(0, len(_value)):
try: _value = eval(_value)
except: pass
if len(_value) == 1: _value = _value
music.play('A3:2')
@blynk.handle_event('write V7')
def write_virtual_pin_handler(pin, _value):
global my_list
for i in range(0, len(_value)):
try: _value = eval(_value)
except: pass
if len(_value) == 1: _value = _value
music.play('B3:2')
oled.fill(0)
oled.DispChar(" 远程八音盒电子琴", 0, 16, 1)
oled.show()
rgb = (int(0), int(51), int(0))
rgb.write()
time.sleep_ms(1)
while True:
blynk.run()
mPython X 实验图形编程
#MicroPython动手做(30)——物联网之Blynk
#远程网络八音盒电子琴 (实验视频)
https://v.youku.com/v_show/id_XNDcwNTQxMzUxMg==.html
https://v.youku.com/v_show/id_XNDcwNTQxMzUxMg==.html
6、Blynk远程控制小车前后左右行驶
#MicroPython动手做(30)——物联网之Blynk
#Blynk远程控制小车前后左右行驶
from mpython import *
import network
import blynklib
import music
import time
import parrot
my_wifi = wifi()
my_wifi.connectWiFi("zh", "zy1567")
blynk = blynklib.Blynk("67988e85a728460fb1d543b9d15e0b5f", server="blynk.mpython.cn", 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):
for i in range(0, len(_value)):
try: _value = eval(_value)
except: pass
if len(_value) == 1: _value = _value
parrot.set_speed(parrot.MOTOR_1, 80)
parrot.set_speed(parrot.MOTOR_2, 80)
@blynk.handle_event('write V2')
def write_virtual_pin_handler(pin, _value):
for i in range(0, len(_value)):
try: _value = eval(_value)
except: pass
if len(_value) == 1: _value = _value
parrot.set_speed(parrot.MOTOR_1, -50)
parrot.set_speed(parrot.MOTOR_2, -50)
@blynk.handle_event('write V3')
def write_virtual_pin_handler(pin, _value):
for i in range(0, len(_value)):
try: _value = eval(_value)
except: pass
if len(_value) == 1: _value = _value
parrot.set_speed(parrot.MOTOR_1, -50)
parrot.set_speed(parrot.MOTOR_2, 50)
@blynk.handle_event('write V4')
def write_virtual_pin_handler(pin, _value):
for i in range(0, len(_value)):
try: _value = eval(_value)
except: pass
if len(_value) == 1: _value = _value
parrot.set_speed(parrot.MOTOR_1, 50)
parrot.set_speed(parrot.MOTOR_2, -50)
@blynk.handle_event('write V5')
def write_virtual_pin_handler(pin, _value):
for i in range(0, len(_value)):
try: _value = eval(_value)
except: pass
if len(_value) == 1: _value = _value
parrot.set_speed(parrot.MOTOR_1, 0)
parrot.set_speed(parrot.MOTOR_2, 0)
oled.fill(0)
oled.DispChar(" 远程控制小车", 0, 1, 1)
oled.show()
music.play('D5:1')
rgb = (int(0), int(51), int(0))
rgb.write()
time.sleep_ms(1)
while True:
blynk.run()
设置的APP控制面板的元素为
mPython X 实验图形编程
#MicroPython动手做(30)——物联网之Blynk
#Blynk远程控制小车前后左右行驶(25秒实验视频)
https://v.youku.com/v_show/id_XNDcyMjk2MTUwMA==.html?spm=a2h0c.8166622.PhoneSokuUgc_1.dtitle
https://v.youku.com/v_show/id_XNDcyMjk2MTUwMA==.html?spm=a2h0c.8166622.PhoneSokuUgc_1.dtitle
页:
1
[2]