Blinky/src/main.cpp

39 lines
767 B
C++

#include <Homie.h>
#include <ArduinoOTA.h>
//D4 auf ground macht led leuchten
#define PIN_LED D4
HomieNode knobNode("blinky", "blinky", "commands");
void setup() {
Serial.begin(115200);
Serial << endl << endl;
pinMode(PIN_LED, OUTPUT);
Homie_setFirmware("blinky", "0.1.0");
Homie.setup();
ArduinoOTA.setHostname(Homie.getConfiguration().deviceId);
ArduinoOTA.onStart([]() {
Homie.getLogger() << "Arduino OTA angefragt" << endl;
});
ArduinoOTA.begin();
}
long lastmillis = 0;
bool stateled = false;
void loop() {
Homie.loop();
ArduinoOTA.handle();
if ((lastmillis+500)<millis()){
Homie.getLogger() << "Switching" << endl;
stateled = !stateled;
digitalWrite(PIN_LED, stateled?HIGH:LOW);
lastmillis = millis();
}
}