c_cpp esp8266.arduino.ticker.ino

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp esp8266.arduino.ticker.ino相关的知识,希望对你有一定的参考价值。

/*
  Passing paramters to Ticker callbacks
  
  Apart from void(void) functions, the Ticker library supports 
  functions taking one argument. This argument's size has to be less or
  equal to 4 bytes (so char, short, int, float, void*, char* types will do).
  
  This sample runs two tickers that both call one callback function,
  but with different arguments.

  An LED connected to GPIO1 will be pulsing. Use a built-in LED on ESP-01
  or connect an external one to TXD on other boards.
*/

#include <Ticker.h>

Ticker tickerSetHigh;
Ticker tickerSetLow;

void setPin(int state) {
//  digitalWrite(1, state);
 char buff[10];
 sprintf(buff, "%lu -> %d", millis(), state);
 Serial.println(buff);
}

void setup() {
  Serial.begin(115200);
  delay(50);
  Serial.println("GOGOGO"); 
  delay(500);
  // every 337 ms, call setPin(0) 
  tickerSetLow.attach_ms(337, setPin, 0);
 
  // every 771 ms, call setPin(1)
  tickerSetHigh.attach_ms(771, setPin, 1);
}

void loop() {
}

以上是关于c_cpp esp8266.arduino.ticker.ino的主要内容,如果未能解决你的问题,请参考以下文章

c_cpp esp8266-webserver.ino

c_cpp esp8266.tv.ino

c_cpp esp8266oled.ino

c_cpp sprintf.esp8266.ino

c_cpp ESP8266使用Web服务器或MQTT进行ESP-01继电器控制

c_cpp ESP32-后Data.ino