|
本帖最后由 lslcxlsl 于 2021-2-23 15:05 编辑
ws2812氛围灯
esp8266+ws2812+blinker wifi远程控制
使用的是blinker的实例代码,没有啥修改
#define PIN D7 这个是接口
#define NUMPIXELS 15 这个是灯珠数量
在app上顶一个取色器,RGBKey
就这么简单
- *
- * Download latest Blinker library here:
- * https://github.com/blinker-iot/blinker-library/archive/master.zip
- *
- *
- * Blinker is a cross-hardware, cross-platform solution for the IoT.
- * It provides APP, device and server support,
- * and uses public cloud services for data transmission and storage.
- * It can be used in smart home, data monitoring and other fields
- * to help users build Internet of Things projects better and faster.
- *
- * Make sure installed 2.5.0 or later ESP8266/Arduino package,
- * if use ESP8266 with Blinker.
- * https://github.com/esp8266/Arduino/releases
- *
- * Make sure installed 1.0.2 or later ESP32/Arduino package,
- * if use ESP32 with Blinker.
- * https://github.com/espressif/arduino-esp32/releases
- *
- * Docs: https://diandeng.tech/doc
- * https://github.com/blinker-iot/blinker-doc/wiki
- *
- * *****************************************************************
- *
- * Blinker 库下载地址:
- * https://github.com/blinker-iot/blinker-library/archive/master.zip
- *
- * Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
- * 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
- * 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
- *
- * 如果使用 ESP8266 接入 Blinker,
- * 请确保安装了 2.5.0 或更新的 ESP8266/Arduino 支持包。
- * https://github.com/esp8266/Arduino/releases
- *
- * 如果使用 ESP32 接入 Blinker,
- * 请确保安装了 1.0.2 或更新的 ESP32/Arduino 支持包。
- * https://github.com/espressif/arduino-esp32/releases
- *
- * 文档: https://diandeng.tech/doc
- * https://github.com/blinker-iot/blinker-doc/wiki
- *
- * *****************************************************************/
- #define BLINKER_WIFI
- #include <Blinker.h>
- char auth[] = "1c87d2335fc8";
- char ssid[] = "abc";
- char pswd[] = "chenxu123";
- // Download Adafruit_NeoPixel library here:
- // https://github.com/adafruit/Adafruit_NeoPixel
- #include <Adafruit_NeoPixel.h>
- #ifdef __AVR__
- #include <avr/power.h>
- #endif
- #define PIN D7
- #define NUMPIXELS 15
- Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
- #define RGB_1 "RGBKey"
- BlinkerRGB WS2812(RGB_1);
- void ws2812_callback(uint8_t r_value, uint8_t g_value, uint8_t b_value, uint8_t bright_value)
- {
- digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
- BLINKER_LOG("R value: ", r_value);
- BLINKER_LOG("G value: ", g_value);
- BLINKER_LOG("B value: ", b_value);
- BLINKER_LOG("Rrightness value: ", bright_value);
- pixels.setBrightness(bright_value);
- for(int i = 0; i < NUMPIXELS; i++){
- pixels.setPixelColor(i, r_value, g_value, b_value);
- }
- pixels.show();
- }
- void setup()
- {
- Serial.begin(115200);
- BLINKER_DEBUG.stream(Serial);
- pinMode(LED_BUILTIN, OUTPUT);
- digitalWrite(LED_BUILTIN, LOW);
- Blinker.begin(auth, ssid, pswd);
- pixels.begin();
- WS2812.attach(ws2812_callback);
- }
- void loop()
- {
- Blinker.run();
- }
复制代码
WS2812_WiFi2021_2_23_.zip
(1.49 KB, 下载次数: 62)
|
|