我加了blinker.delay后我的手机端还是识别不到,而用例程就可以。我把dht11的库重新换了一个和删掉dht11部分的尝试,都不行。下面是代码:
#define BLINKER_PRINT Serial
#define BLINKER_WIFI
#include <Blinker.h>
char ssid[] = "Tenda_299C18";
char pswd[] = "13715860937";
#define BUTTON_1 "a"//控制水泵的按钮
#define BUTTON_2 "e"
#define BUTTON_3 "f"
#define KG_1 "b"//切换模式的按钮
#define KG_2 "c"//在较干燥的的时候才浇水按钮
#define KG_3 "d"//与kg3相反
int a=5;//水泵定义
int b=A0;//土壤传感器定义
int c=6;//温湿度传感器定义
int l=7;//电源灯定义
int x=0;//变量
int y=0;//变量
void ZD(){
x=analogRead(b);
if(x>=630&&x<=750){
digitalWrite(a,HIGH);
}else{
digitalWrite(a,LOW);
}
}
void S(){
if(Blinker.button(BUTTON_1)){
digitalWrite(a,HIGH);
}else{
digitalWrite(a,HIGH);
}
}
void TU(){
x=analogRead(b);
if(x>=630&&x<=750){
Blinker.println("Current soil moisture is normal");
}
if(x>750&&x<=920){
Blinker.println("The soil is dry at present");
}
if(x>=420&&x<630){
Blinker.println("The soil is moist now");
}
if(x<420){
Blinker.println("The current sensor is completely underwater");
}
if(x>920){
Blinker.println("Please check if your sensor is in the flowerpot");
}
Blinker.delay(2000);
}
void setup()
{
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
pinMode(a,OUTPUT);
pinMode(b,INPUT);
pinMode(c,INPUT);
pinMode(l,OUTPUT);
Blinker.wInit(BUTTON_1, W_BUTTON);
Blinker.wInit(BUTTON_2, W_BUTTON);
Blinker.wInit(BUTTON_3, W_BUTTON);
Blinker.wInit(KG_1,W_TOGGLE);
Blinker.wInit(KG_2,W_TOGGLE);
Blinker.wInit(KG_3,W_TOGGLE);
Blinker.begin(ssid, pswd);
}
void loop()
{
Blinker.run();
if (Blinker.available()) {
BLINKER_LOG2("Blinker.readString(): ", Blinker.readString());
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print(BlinkerTime);
Blinker.print("millis", BlinkerTime);
}
if(Blinker.toggle(KG_1)){
ZD();
}else{
S();
}
if(Blinker.button(BUTTON_2)){
}
if(Blinker.button(BUTTON_3)){
TU();
}
}
|