Blinky/src/main.cpp

39 lines
767 B
C++
Raw Normal View History

2022-08-30 15:34:15 +00:00
#include <Homie.h>
#include <ArduinoOTA.h>
//D4 auf ground macht led leuchten
#define PIN_LED D4
HomieNode knobNode("blinky", "blinky", "commands");
2022-08-30 15:15:12 +00:00
void setup() {
2022-08-30 15:34:15 +00:00
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();
2022-08-30 15:15:12 +00:00
}
2022-08-30 15:42:46 +00:00
long lastmillis = 0;
bool stateled = false;
2022-08-30 15:15:12 +00:00
void loop() {
2022-08-30 15:34:15 +00:00
Homie.loop();
ArduinoOTA.handle();
2022-08-30 15:42:46 +00:00
if ((lastmillis+500)<millis()){
Homie.getLogger() << "Switching" << endl;
stateled = !stateled;
digitalWrite(PIN_LED, stateled?HIGH:LOW);
lastmillis = millis();
}
2022-08-30 15:34:15 +00:00
}