/** * ---------------------------------------------------------------------------- * ESP32 Remote Control with WebSocket * ---------------------------------------------------------------------------- * © 2020 Stéphane Calderoni * ---------------------------------------------------------------------------- */ #include // ---------------------------------------------------------------------------- // Definition of macros // ---------------------------------------------------------------------------- #define LED_PIN 26 // ---------------------------------------------------------------------------- // Definition of the LED component // ---------------------------------------------------------------------------- struct Led { // state variables uint8_t pin; bool on; // methods void update() { digitalWrite(pin, on ? HIGH : LOW); } }; // ---------------------------------------------------------------------------- // Definition of global variables // ---------------------------------------------------------------------------- Led led = { LED_PIN, false }; // ---------------------------------------------------------------------------- // Initialization // ---------------------------------------------------------------------------- void setup() { pinMode(led.pin, OUTPUT); } // ---------------------------------------------------------------------------- // Main control loop // ---------------------------------------------------------------------------- void loop() { led.on = millis() % 1000 < 50; led.update(); }