有谁指导下 WiFiduino 定时器的使用?
有谁指导下 WiFiduino 定时器的使用?实在是没这方面的资料,百度上也没有找到已解决
#include <ESP8266WiFi.h>
const char* ssid = "newifi";
const char* password = "87257258";
#include <Ticker.h>
Ticker ticker;
int count = 0;
void Tickertest()
{
int state = digitalRead(LED_BUILTIN);
digitalWrite(LED_BUILTIN, !state);
++count;
Serial.println(count);
Serial.println(WiFi.localIP());
Serial.println("");
}
void setup() {
WiFi.mode(WIFI_STA);//工作模式
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {//判断是否连上
delay(2000);
Serial.print(".");
}
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
//间隔1秒
ticker.attach(1, Tickertest);
}
void loop() {
} :loveliness:
有情况 还是用rtos好解决多任务问题
页:
[1]