[ESP32+MicroPython]快速接入blinker-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 3110|回复: 4

[ESP32+MicroPython]快速接入blinker

[复制链接]
发表于 2019-8-5 05:10 | 显示全部楼层 |阅读模式




[pre]#!/usr/bin/env python
# -*- coding: utf-8 -*-

from machine import Pin

from Blinker.Blinker import Blinker, BlinkerButton, BlinkerNumber
from Blinker.BlinkerDebug import *

auth = 'Your Device Secret Key'
ssid = 'Your WiFi network SSID or name'
pswd = 'Your WiFi network WPA password or WEP key'

BLINKER_DEBUG.debugAll()

Blinker.mode('BLINKER_WIFI')
Blinker.begin(auth, ssid, pswd)

button1 = BlinkerButton('btn-abc')
number1 = BlinkerNumber('num-abc')

counter = 0
pinValue = 0

p2 = Pin(2, Pin.OUT)
p2.value(pinValue)

def button1_callback(state):
    ''' '''

    BLINKER_LOG('get button state: ', state)

    button1.icon('icon_1')
    button1.color('#FFFFFF')
    button1.text('Your button name or describe')
    button1.print(state)

    global pinValue
   
    pinValue = 1 - pinValue
    p2.value(pinValue)

def data_callback(data):
    global counter
   
    BLINKER_LOG('Blinker readString: ', data)
    counter += 1
    number1.print(counter)

button1.attach(button1_callback)
Blinker.attachData(data_callback)

if __name__ == '__main__':

    while True:
        Blinker.run()[/pre]
发表于 2020-3-17 14:58 | 显示全部楼层
from Blinker.Blinker import Blinker, BlinkerButton, BlinkerNumber 出错,memoryerror:memory allocation failed,allocation个136bytes,怎么破?
发表于 2019-8-5 15:09 | 显示全部楼层
快速接入blinker    www.tdszx.com  www.jyhxjm.com  www.gztpcj.com
发表于 2020-8-6 12:57 | 显示全部楼层
请问大神:我用的mincropython IDE是uPyCcaft,不知道如何安装blinker-mpy-master 库。查遍网络,找不到一篇文章讲解,请教大神指导
发表于 2020-8-6 12:58 | 显示全部楼层
也用thonny IDE,但还是无法安装blinker-mpy-master库
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-11-28 11:32 , Processed in 0.079897 second(s), 16 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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