|
开发板用过uno和mega2560试过,下面是根据hello_ble进行了小修改的程序
#define BLINKER_BLE
#include <Blinker.h>
BlinkerButton Button1("btn-abc");
BlinkerNumber Number1("num-abc");
int counter = 0;
void button1_callback(const String & state)
{
BLINKER_LOG("get button state: ", state);
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
counter++;
Number1.print(counter);
}
void setup()
{
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
Blinker.begin(2,3,115200);
Blinker.attachData(dataRead);
Button1.attach(button1_callback);
}
void loop()
{
Blinker.run();
} |
|