|
- 硬件: Arduino UNO 蓝牙模块 JDY-10 2.23版本
- 接入方式: BLE
- package版本:
- blinker库版本: arduino 0.3.2
- 开发环境: Arduino 1.8.11
- 操作系统: Windows 10 x64
- 手机ONE PLUS A5000
- 无法正常通信
-
APP 版本2.2.7
Arduino串口
- APP版本2.2.7
- 程序如下:使用Blinker自带的例程。
#define BLINKER_BLE
#include <Blinker.h>
#define BUTTON_1 "ButtonKey"
BlinkerButton Button1(BUTTON_1);
void button1_callback(const String & state){ digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); BLINKER_LOG("get button state: ", state); Serial.print(state); Button1.print(state); Button1.print("OK");
if (state == BLINKER_CMD_BUTTON_TAP) { BLINKER_LOG("Button tap!");
Button1.icon("icon_1"); Button1.color("#FFFFFF"); Button1.text("Your button name or describe"); // Button1.text("Your button name", "describe"); Button1.print("Button tap!"); } else if (state == BLINKER_CMD_BUTTON_PRESSED) { BLINKER_LOG("Button pressed!");
Button1.icon("icon_1"); Button1.color("#FFFFFF"); Button1.text("Your button name or describe"); // Button1.text("Your button name", "describe"); Button1.print("Button pressed!"); } else if (state == BLINKER_CMD_BUTTON_RELEASED) { BLINKER_LOG("Button released!");
Button1.icon("icon_1"); Button1.color("#FFFFFF"); Button1.text("Your button name or describe"); // Button1.text("Your button name", "describe"); Button1.print("Button released!"); } else if (state == BLINKER_CMD_ON) { BLINKER_LOG("Toggle on!");
Button1.icon("icon_1"); Button1.color("#FFFFFF"); Button1.text("Your button name or describe"); // Button1.text("Your button name", "describe"); Button1.print("on"); } else if (state == BLINKER_CMD_OFF) { BLINKER_LOG("Toggle off!");
Button1.icon("icon_1"); Button1.color("#FFFFFF"); Button1.text("Your button name or describe"); // Button1.text("Your button name", "describe"); Button1.print("off"); } else { BLINKER_LOG("Get user setting: ", state);
Button1.icon("icon_1"); Button1.color("#FFFFFF"); Button1.text("Your button name or describe"); Button1.print(); }}
void dataRead(const String & data){ BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate(); uint32_t BlinkerTime = millis(); Blinker.print("millis", BlinkerTime);}
void setup(){ Serial.begin(9600); BLINKER_DEBUG.stream(Serial);
pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW);
Blinker.begin(2,3,115200); Button1.attach(button1_callback); Blinker.attachData(dataRead);}
void loop(){ Blinker.run();} - 串口显示 无显示
- 接线方式 ble ---------- UNO
- gnd ---------- gnd
- vcc ----------- 3.3V
- tx ------------ 2
- rx ------------ 3
|
|