Jump to content
  • Виджеты

    JOYSTICK

    ESP8266 WIFI

    Спойлер
    /*************************************************************
    
      Datastreams setup:
        Add a Virtual Pin Datastream called "Joystick" on V1. Select type: "String".
    
      App dashboard setup:
        Add a Joystick widget, select Advanced output mode. Attach it to "Joystick" DS.
    
      NOTE: Advanced mode means device will receive both x and y on a single Datastream
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    BLYNK_WRITE(V1) {
      int x = param[0].asInt();
      int y = param[1].asInt();
    
      // Do something with x and y
      Serial.print("X = ");
      Serial.print(x);
      Serial.print("; Y = ");
      Serial.println(y);
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
    }
    
    void loop()
    {
      Blynk.run();
    }

    ESP32 WIFI

    Спойлер
    /*************************************************************
    
      Datastreams setup:
        Add a Virtual Pin Datastream called "Joystick" on V1. Select type: "String".
    
      App dashboard setup:
        Add a Joystick widget, select Advanced output mode. Attach it to "Joystick" DS.
    
      NOTE: Advanced mode means device will receive both x and y on a single Datastream
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <WiFi.h>
    #include <WiFiClient.h>
    #include <BlynkSimpleEsp32.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    BLYNK_WRITE(V1) {
      int x = param[0].asInt();
      int y = param[1].asInt();
    
      // Do something with x and y
      Serial.print("X = ");
      Serial.print(x);
      Serial.print("; Y = ");
      Serial.println(y);
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
    }
    
    void loop()
    {
      Blynk.run();
    }

    ARDUINO UNO|MEGA (Arduino Ethernet shield (W5100))

    Спойлер
    /*************************************************************
      This example shows how to use Arduino Ethernet shield (W5100)
      to connect your project to Blynk.
    
      NOTE: Pins 10, 11, 12 and 13 are reserved for Ethernet module.
            DON'T use them in your sketch directly!
    
      WARNING: If you have an SD card, you may need to disable it
            by setting pin 4 to HIGH. Read more here:
            https://www.arduino.cc/en/Main/ArduinoEthernetShield
    
      Datastreams setup:
        Add a Virtual Pin Datastream called "Joystick" on V1. Select type: "String".
    
      App dashboard setup:
        Add a Joystick widget, select Advanced output mode. Attach it to "Joystick" DS.
    
      NOTE: Advanced mode means device will receive both x and y on a single Datastream
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <SPI.h>
    #include <Ethernet.h>
    #include <BlynkSimpleEthernet.h>
    
    #define W5100_CS  10
    #define SDCARD_CS 4
    
    BLYNK_WRITE(V1) {
      int x = param[0].asInt();
      int y = param[1].asInt();
    
      // Do something with x and y
      Serial.print("X = ");
      Serial.print(x);
      Serial.print("; Y = ");
      Serial.println(y);
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      pinMode(SDCARD_CS, OUTPUT);
      digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
    
      Blynk.begin(BLYNK_AUTH_TOKEN);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(192,168,1,100), 8080);
    }
    
    void loop()
    {
      Blynk.run();
    }

     

    LCD SIMPLE MODE

    ESP8266 WIFI

    Спойлер
    /*************************************************************
    
      Output any data on LCD widget!
    
      App dashboard setup:
    
        LCD widget, SIMPLE mode, in widget settings :
    
        - Select pin V0 for zero pin
        - Select pin V1 for first pin
        - Change "Reading Frequency" to PUSH mode
        - Type into first edit field "/pin0/ seconds"
        - Type into second edit field "/pin1/ millis"
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    BlynkTimer timer;
    
    void sendSeconds() {
      Blynk.virtualWrite(V0, millis() / 1000);
    }
    
    void sendMillis() {
      Blynk.virtualWrite(V1, millis());
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    
      // Setup a function to be called every second
      timer.setInterval(1000L, sendSeconds);
      // Setup a function to be called every second
      timer.setInterval(1000L, sendMillis);
    }
    
    void loop()
    {
      Blynk.run();
      timer.run();
    }

    ESP32 WIFI

    Спойлер
    /*************************************************************
    
      Output any data on LCD widget!
    
      App dashboard setup:
    
        LCD widget, SIMPLE mode, in widget settings :
    
        - Select pin V0 for zero pin
        - Select pin V1 for first pin
        - Change "Reading Frequency" to PUSH mode
        - Type into first edit field "/pin0/ seconds"
        - Type into second edit field "/pin1/ millis"
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <WiFi.h>
    #include <WiFiClient.h>
    #include <BlynkSimpleEsp32.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    BlynkTimer timer;
    
    void sendSeconds() {
      Blynk.virtualWrite(V0, millis() / 1000);
    }
    
    void sendMillis() {
      Blynk.virtualWrite(V1, millis());
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    
      // Setup a function to be called every second
      timer.setInterval(1000L, sendSeconds);
      // Setup a function to be called every second
      timer.setInterval(1000L, sendMillis);
    }
    
    void loop()
    {
      Blynk.run();
      timer.run();
    }

    ARDUINO UNO|MEGA (Arduino Ethernet shield (W5100))

    Спойлер
    /*************************************************************
      This example shows how to use Arduino Ethernet shield (W5100)
      to connect your project to Blynk.
    
      NOTE: Pins 10, 11, 12 and 13 are reserved for Ethernet module.
            DON'T use them in your sketch directly!
    
      WARNING: If you have an SD card, you may need to disable it
            by setting pin 4 to HIGH. Read more here:
            https://www.arduino.cc/en/Main/ArduinoEthernetShield
    
      Output any data on LCD widget!
    
      App dashboard setup:
    
        LCD widget, SIMPLE mode, in widget settings :
    
        - Select pin V0 for zero pin
        - Select pin V1 for first pin
        - Change "Reading Frequency" to PUSH mode
        - Type into first edit field "/pin0/ seconds"
        - Type into second edit field "/pin1/ millis"
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <SPI.h>
    #include <Ethernet.h>
    #include <BlynkSimpleEthernet.h>
    
    #define W5100_CS  10
    #define SDCARD_CS 4
    
    BlynkTimer timer;
    
    void sendSeconds() {
      Blynk.virtualWrite(V0, millis() / 1000);
    }
    
    void sendMillis() {
      Blynk.virtualWrite(V1, millis());
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      pinMode(SDCARD_CS, OUTPUT);
      digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
    
      Blynk.begin(BLYNK_AUTH_TOKEN);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(91,204,228,77), 8480);
    
      // Setup a function to be called every second
      timer.setInterval(1000L, sendSeconds);
      // Setup a function to be called every second
      timer.setInterval(1000L, sendMillis);
    }
    
    void loop()
    {
      Blynk.run();
      timer.run();
    }

     

     

    LCD SIMPLE MODE

    ESP8266 WIFI

    Спойлер
    /*************************************************************
    
      Output any data on LCD widget!
    
      App dashboard setup:
        LCD widget, switch to ADVANCED mode, select pin V1
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    WidgetLCD lcd(V1);
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    
      lcd.clear(); //Use it to clear the LCD Widget
      lcd.print(4, 0, "Hello"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print")
      lcd.print(4, 1, "World");
      // Please use timed events when LCD printintg in void loop to avoid sending too many commands
      // It will cause a FLOOD Error, and connection will be dropped
    }
    
    void loop()
    {
      Blynk.run();
    }

    ESP32 WIFI

    Спойлер
    /*************************************************************
    
      Output any data on LCD widget!
    
      App dashboard setup:
        LCD widget, switch to ADVANCED mode, select pin V1
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <WiFi.h>
    #include <WiFiClient.h>
    #include <BlynkSimpleEsp32.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    WidgetLCD lcd(V1);
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    
      lcd.clear(); //Use it to clear the LCD Widget
      lcd.print(4, 0, "Hello"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print")
      lcd.print(4, 1, "World");
      // Please use timed events when LCD printintg in void loop to avoid sending too many commands
      // It will cause a FLOOD Error, and connection will be dropped
    }
    
    void loop()
    {
      Blynk.run();
    }

    ARDUINO UNO|MEGA (Arduino Ethernet shield (W5100))

    Спойлер
    /*************************************************************
      This example shows how to use Arduino Ethernet shield (W5100)
      to connect your project to Blynk.
    
      NOTE: Pins 10, 11, 12 and 13 are reserved for Ethernet module.
            DON'T use them in your sketch directly!
    
      WARNING: If you have an SD card, you may need to disable it
            by setting pin 4 to HIGH. Read more here:
            https://www.arduino.cc/en/Main/ArduinoEthernetShield
    
      Output any data on LCD widget!
    
      App dashboard setup:
        LCD widget, switch to ADVANCED mode, select pin V1
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <SPI.h>
    #include <Ethernet.h>
    #include <BlynkSimpleEthernet.h>
    
    #define W5100_CS  10
    #define SDCARD_CS 4
    
    WidgetLCD lcd(V1);
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      pinMode(SDCARD_CS, OUTPUT);
      digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
    
      Blynk.begin(BLYNK_AUTH_TOKEN);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(91,204,228,77), 8480);
    
      lcd.clear(); //Use it to clear the LCD Widget
      lcd.print(4, 0, "Hello"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print")
      lcd.print(4, 1, "World");
      // Please use timed events when LCD printintg in void loop to avoid sending too many commands
      // It will cause a FLOOD Error, and connection will be dropped
    }
    
    void loop()
    {
      Blynk.run();
    }

     

    LED BLINK

    ESP8266 WIFI

    Спойлер
    /*************************************************************
    
      Blynk using a LED widget on your phone!
    
      App dashboard setup:
        LED widget on V1
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    WidgetLED led1(V1);
    
    BlynkTimer timer;
    
    // V1 LED Widget is blinking
    void blinkLedWidget()
    {
      if (led1.getValue()) {
        led1.off();
        Serial.println("LED on V1: off");
      } else {
        led1.on();
        Serial.println("LED on V1: on");
      }
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    
      timer.setInterval(1000L, blinkLedWidget);
    }
    
    void loop()
    {
      Blynk.run();
      timer.run();
    }

     

    ESP32 WIFI

    Спойлер
    /*************************************************************
    
      Blynk using a LED widget on your phone!
    
      App dashboard setup:
        LED widget on V1
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <WiFi.h>
    #include <WiFiClient.h>
    #include <BlynkSimpleEsp32.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    WidgetLED led1(V1);
    
    BlynkTimer timer;
    
    // V1 LED Widget is blinking
    void blinkLedWidget()
    {
      if (led1.getValue()) {
        led1.off();
        Serial.println("LED on V1: off");
      } else {
        led1.on();
        Serial.println("LED on V1: on");
      }
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    
      timer.setInterval(1000L, blinkLedWidget);
    }
    
    void loop()
    {
      Blynk.run();
      timer.run();
    }

    ARDUINO UNO|MEGA (Arduino Ethernet shield (W5100))

    Спойлер
    /*************************************************************
      This example shows how to use Arduino Ethernet shield (W5100)
      to connect your project to Blynk.
    
      NOTE: Pins 10, 11, 12 and 13 are reserved for Ethernet module.
            DON'T use them in your sketch directly!
    
      WARNING: If you have an SD card, you may need to disable it
            by setting pin 4 to HIGH. Read more here:
            https://www.arduino.cc/en/Main/ArduinoEthernetShield
    
      Blynk using a LED widget on your phone!
    
      App dashboard setup:
        LED widget on V1
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <SPI.h>
    #include <Ethernet.h>
    #include <BlynkSimpleEthernet.h>
    
    #define W5100_CS  10
    #define SDCARD_CS 4
    
    WidgetLED led1(V1);
    
    BlynkTimer timer;
    
    // V1 LED Widget is blinking
    void blinkLedWidget()
    {
      if (led1.getValue()) {
        led1.off();
        Serial.println("LED on V1: off");
      } else {
        led1.on();
        Serial.println("LED on V1: on");
      }
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      pinMode(SDCARD_CS, OUTPUT);
      digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
    
      Blynk.begin(BLYNK_AUTH_TOKEN);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(91,204,228,77), 8480);
    
      timer.setInterval(1000L, blinkLedWidget);
    }
    
    void loop()
    {
      Blynk.run();
      timer.run();
    }

     

    LED COLOR

    ESP8266 WIFI

    Спойлер
    /*************************************************************
    
      Blynk using a LED widget on your phone!
    
      App dashboard setup:
        LED widget on V1
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    WidgetLED led1(V1);
    
    BlynkTimer timer;
    bool ledStatus = false;
    
    #define BLYNK_GREEN     "#23C48E"
    #define BLYNK_BLUE      "#04C0F8"
    #define BLYNK_YELLOW    "#ED9D00"
    #define BLYNK_RED       "#D3435C"
    #define BLYNK_DARK_BLUE "#5F7CD8"
    
    // V1 LED Widget is blinking
    void blinkLedWidget()
    {
      if (ledStatus) {
        led1.setColor(BLYNK_RED);
        Serial.println("LED on V1: red");
        ledStatus = false;
      } else {
        led1.setColor(BLYNK_GREEN);
        Serial.println("LED on V1: green");
        ledStatus = true;
      }
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    
      // Turn LED on, so colors are visible
      led1.on();
      // Setup periodic color change
      timer.setInterval(1000L, blinkLedWidget);
    }
    
    void loop()
    {
      Blynk.run();
      timer.run();
    }

    ESP32 WIFI

    Спойлер
    /*************************************************************
    
      Blynk using a LED widget on your phone!
    
      App dashboard setup:
        LED widget on V1
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <WiFi.h>
    #include <WiFiClient.h>
    #include <BlynkSimpleEsp32.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    WidgetLED led1(V1);
    
    BlynkTimer timer;
    bool ledStatus = false;
    
    #define BLYNK_GREEN     "#23C48E"
    #define BLYNK_BLUE      "#04C0F8"
    #define BLYNK_YELLOW    "#ED9D00"
    #define BLYNK_RED       "#D3435C"
    #define BLYNK_DARK_BLUE "#5F7CD8"
    
    // V1 LED Widget is blinking
    void blinkLedWidget()
    {
      if (ledStatus) {
        led1.setColor(BLYNK_RED);
        Serial.println("LED on V1: red");
        ledStatus = false;
      } else {
        led1.setColor(BLYNK_GREEN);
        Serial.println("LED on V1: green");
        ledStatus = true;
      }
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    
      // Turn LED on, so colors are visible
      led1.on();
      // Setup periodic color change
      timer.setInterval(1000L, blinkLedWidget);
    }
    
    void loop()
    {
      Blynk.run();
      timer.run();
    }

    ARDUINO UNO|MEGA (Arduino Ethernet shield (W5100))

    Спойлер
    /*************************************************************
      This example shows how to use Arduino Ethernet shield (W5100)
      to connect your project to Blynk.
    
      NOTE: Pins 10, 11, 12 and 13 are reserved for Ethernet module.
            DON'T use them in your sketch directly!
    
      WARNING: If you have an SD card, you may need to disable it
            by setting pin 4 to HIGH. Read more here:
            https://www.arduino.cc/en/Main/ArduinoEthernetShield
    
      Blynk using a LED widget on your phone!
    
      App dashboard setup:
        LED widget on V1
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <SPI.h>
    #include <Ethernet.h>
    #include <BlynkSimpleEthernet.h>
    
    #define W5100_CS  10
    #define SDCARD_CS 4
    
    WidgetLED led1(V1);
    
    BlynkTimer timer;
    bool ledStatus = false;
    
    #define BLYNK_GREEN     "#23C48E"
    #define BLYNK_BLUE      "#04C0F8"
    #define BLYNK_YELLOW    "#ED9D00"
    #define BLYNK_RED       "#D3435C"
    #define BLYNK_DARK_BLUE "#5F7CD8"
    
    // V1 LED Widget is blinking
    void blinkLedWidget()
    {
      if (ledStatus) {
        led1.setColor(BLYNK_RED);
        Serial.println("LED on V1: red");
        ledStatus = false;
      } else {
        led1.setColor(BLYNK_GREEN);
        Serial.println("LED on V1: green");
        ledStatus = true;
      }
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      pinMode(SDCARD_CS, OUTPUT);
      digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
    
      Blynk.begin(BLYNK_AUTH_TOKEN);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(91,204,228,77), 8480);
    
      // Turn LED on, so colors are visible
      led1.on();
      // Setup periodic color change
      timer.setInterval(1000L, blinkLedWidget);
    }
    
    void loop()
    {
      Blynk.run();
      timer.run();
    }

     

    LED FADE

    ESP8266 WIFI

    Спойлер
    /*************************************************************
    
      Fade using a LED widget on your phone!
    
      App dashboard setup:
        LED widget on V2
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    WidgetLED led2(V2);
    
    BlynkTimer timer;
    
    // V2 LED Widget is fading
    void fadeLedWidget()
    {
      static int value = 0;
      static int delta = 30;
      value += delta;
      if (value > 255 || value < 0) {
        delta = -delta;
      } else {
        Serial.print("LED on V2: ");
        Serial.println(value);
        led2.setValue(value);
      }
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    
      timer.setInterval(300L, fadeLedWidget);
    }
    
    void loop()
    {
      Blynk.run();
      timer.run();
    }

    ESP32 WIFI

    Спойлер
    /*************************************************************
    
      Fade using a LED widget on your phone!
    
      App dashboard setup:
        LED widget on V2
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <WiFi.h>
    #include <WiFiClient.h>
    #include <BlynkSimpleEsp32.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    WidgetLED led2(V2);
    
    BlynkTimer timer;
    
    // V2 LED Widget is fading
    void fadeLedWidget()
    {
      static int value = 0;
      static int delta = 30;
      value += delta;
      if (value > 255 || value < 0) {
        delta = -delta;
      } else {
        Serial.print("LED on V2: ");
        Serial.println(value);
        led2.setValue(value);
      }
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    
      timer.setInterval(300L, fadeLedWidget);
    }
    
    void loop()
    {
      Blynk.run();
      timer.run();
    }

    ARDUINO UNO|MEGA (Arduino Ethernet shield (W5100))

    Спойлер
    /*************************************************************
      This example shows how to use Arduino Ethernet shield (W5100)
      to connect your project to Blynk.
    
      NOTE: Pins 10, 11, 12 and 13 are reserved for Ethernet module.
            DON'T use them in your sketch directly!
    
      WARNING: If you have an SD card, you may need to disable it
            by setting pin 4 to HIGH. Read more here:
            https://www.arduino.cc/en/Main/ArduinoEthernetShield
    
      Fade using a LED widget on your phone!
    
      App dashboard setup:
        LED widget on V2
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <SPI.h>
    #include <Ethernet.h>
    #include <BlynkSimpleEthernet.h>
    
    #define W5100_CS  10
    #define SDCARD_CS 4
    
    WidgetLED led2(V2);
    
    BlynkTimer timer;
    
    // V2 LED Widget is fading
    void fadeLedWidget()
    {
      static int value = 0;
      static int delta = 30;
      value += delta;
      if (value > 255 || value < 0) {
        delta = -delta;
      } else {
        Serial.print("LED on V2: ");
        Serial.println(value);
        led2.setValue(value);
      }
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      pinMode(SDCARD_CS, OUTPUT);
      digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
    
      Blynk.begin(BLYNK_AUTH_TOKEN);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(91,204,228,77), 8480);
    
      timer.setInterval(300L, fadeLedWidget);
    }
    
    void loop()
    {
      Blynk.run();
      timer.run();
    }

     

    LED STATUS OF BUTTON

    ESP8266 WIFI

    Спойлер
    /*************************************************************
    
      Blynk using a LED widget on your phone!
    
      App dashboard setup:
        LED widget on V3
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    // Select your pin with physical button
    const int btnPin = 1;
    
    WidgetLED led3(V3);
    
    BlynkTimer timer;
    
    // V3 LED Widget represents the physical button state
    boolean btnState = false;
    void buttonLedWidget()
    {
      // Read button
      boolean isPressed = (digitalRead(btnPin) == LOW);
    
      // If state has changed...
      if (isPressed != btnState) {
        if (isPressed) {
          led3.on();
        } else {
          led3.off();
        }
        btnState = isPressed;
      }
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
    
      // Setup physical button pin (active low)
      pinMode(btnPin, INPUT_PULLUP);
    
      timer.setInterval(500L, buttonLedWidget);
    }
    
    void loop()
    {
      Blynk.run();
      timer.run();
    }

    ESP32 WIFI

    Спойлер
    /*************************************************************
    
      Blynk using a LED widget on your phone!
    
      App dashboard setup:
        LED widget on V3
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <WiFi.h>
    #include <WiFiClient.h>
    #include <BlynkSimpleEsp32.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    // Select your pin with physical button
    const int btnPin = 1;
    
    WidgetLED led3(V3);
    
    BlynkTimer timer;
    
    // V3 LED Widget represents the physical button state
    boolean btnState = false;
    void buttonLedWidget()
    {
      // Read button
      boolean isPressed = (digitalRead(btnPin) == LOW);
    
      // If state has changed...
      if (isPressed != btnState) {
        if (isPressed) {
          led3.on();
        } else {
          led3.off();
        }
        btnState = isPressed;
      }
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    
      // Setup physical button pin (active low)
      pinMode(btnPin, INPUT_PULLUP);
    
      timer.setInterval(500L, buttonLedWidget);
    }
    
    void loop()
    {
      Blynk.run();
      timer.run();
    }

    ARDUINO UNO|MEGA (Arduino Ethernet shield (W5100))

    Спойлер
    /*************************************************************
      This example shows how to use Arduino Ethernet shield (W5100)
      to connect your project to Blynk.
    
      NOTE: Pins 10, 11, 12 and 13 are reserved for Ethernet module.
            DON'T use them in your sketch directly!
    
      WARNING: If you have an SD card, you may need to disable it
            by setting pin 4 to HIGH. Read more here:
            https://www.arduino.cc/en/Main/ArduinoEthernetShield
    
      Blynk using a LED widget on your phone!
    
      App dashboard setup:
        LED widget on V3
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <SPI.h>
    #include <Ethernet.h>
    #include <BlynkSimpleEthernet.h>
    
    #define W5100_CS  10
    #define SDCARD_CS 4
    
    // Select your pin with physical button
    const int btnPin = 1;
    
    WidgetLED led3(V3);
    
    BlynkTimer timer;
    
    // V3 LED Widget represents the physical button state
    boolean btnState = false;
    void buttonLedWidget()
    {
      // Read button
      boolean isPressed = (digitalRead(btnPin) == LOW);
    
      // If state has changed...
      if (isPressed != btnState) {
        if (isPressed) {
          led3.on();
        } else {
          led3.off();
        }
        btnState = isPressed;
      }
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      pinMode(SDCARD_CS, OUTPUT);
      digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
    
      Blynk.begin(BLYNK_AUTH_TOKEN);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(91,204,228,77), 8480);
    
      // Setup physical button pin (active low)
      pinMode(btnPin, INPUT_PULLUP);
    
      timer.setInterval(500L, buttonLedWidget);
    }
    
    void loop()
    {
      Blynk.run();
      timer.run();
    }

     

    MENU

    ESP8266 WIFI

    Спойлер
    /*************************************************************
    
      This example shows how to use the Menu Widget.
    
      App dashboard setup:
        Menu widget attached to V1 (put 3 items in it)
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    BLYNK_WRITE(V1) {
      switch (param.asInt())
      {
        case 1: // Item 1
          Serial.println("Item 1 selected");
          break;
        case 2: // Item 2
          Serial.println("Item 2 selected");
          break;
        case 3: // Item 3
          Serial.println("Item 3 selected");
          break;
        default:
          Serial.println("Unknown item selected");
      }
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    }
    
    void loop()
    {
      Blynk.run();
    }

    ESP32 WIFI

    Спойлер
    /*************************************************************
    
      This example shows how to use the Menu Widget.
    
      App dashboard setup:
        Menu widget attached to V1 (put 3 items in it)
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <WiFi.h>
    #include <WiFiClient.h>
    #include <BlynkSimpleEsp32.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    BLYNK_WRITE(V1) {
      switch (param.asInt())
      {
        case 1: // Item 1
          Serial.println("Item 1 selected");
          break;
        case 2: // Item 2
          Serial.println("Item 2 selected");
          break;
        case 3: // Item 3
          Serial.println("Item 3 selected");
          break;
        default:
          Serial.println("Unknown item selected");
      }
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    }
    
    void loop()
    {
      Blynk.run();
    }

    ARDUINO UNO|MEGA (Arduino Ethernet shield (W5100))

    Спойлер
    /*************************************************************
      This example shows how to use Arduino Ethernet shield (W5100)
      to connect your project to Blynk.
    
      NOTE: Pins 10, 11, 12 and 13 are reserved for Ethernet module.
            DON'T use them in your sketch directly!
    
      WARNING: If you have an SD card, you may need to disable it
            by setting pin 4 to HIGH. Read more here:
            https://www.arduino.cc/en/Main/ArduinoEthernetShield
    
      This example shows how to use the Menu Widget.
    
      App dashboard setup:
        Menu widget attached to V1 (put 3 items in it)
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <SPI.h>
    #include <Ethernet.h>
    #include <BlynkSimpleEthernet.h>
    
    #define W5100_CS  10
    #define SDCARD_CS 4
    
    BLYNK_WRITE(V1) {
      switch (param.asInt())
      {
        case 1: // Item 1
          Serial.println("Item 1 selected");
          break;
        case 2: // Item 2
          Serial.println("Item 2 selected");
          break;
        case 3: // Item 3
          Serial.println("Item 3 selected");
          break;
        default:
          Serial.println("Unknown item selected");
      }
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      pinMode(SDCARD_CS, OUTPUT);
      digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
    
      Blynk.begin(BLYNK_AUTH_TOKEN);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(91,204,228,77), 8480);
    }
    
    void loop()
    {
      Blynk.run();
    }

     

    MUSIC PLAYER

    ESP8266 WIFI

    Спойлер
    /*************************************************************
    
      This example shows how you can process commands from player widget
    
      App dashboard setup:
        Music Player widget attached to V5
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    BLYNK_WRITE(V5)
    {
      String action = param.asStr();
    
      if (action == "play") {
        // Do something
      }
      if (action == "stop") {
        // Do something
      }
      if (action == "next") {
        // Do something
      }
      if (action == "prev") {
        // Do something
      }
    
      Blynk.setProperty(V5, "label", action);
      Serial.print(action);
      Serial.println();
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    }
    
    void loop()
    {
      Blynk.run();
    }

    ESP32 WIFI

    Спойлер
    /*************************************************************
    
      This example shows how you can process commands from player widget
    
      App dashboard setup:
        Music Player widget attached to V5
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <WiFi.h>
    #include <WiFiClient.h>
    #include <BlynkSimpleEsp32.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    BLYNK_WRITE(V5)
    {
      String action = param.asStr();
    
      if (action == "play") {
        // Do something
      }
      if (action == "stop") {
        // Do something
      }
      if (action == "next") {
        // Do something
      }
      if (action == "prev") {
        // Do something
      }
    
      Blynk.setProperty(V5, "label", action);
      Serial.print(action);
      Serial.println();
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    }
    
    void loop()
    {
      Blynk.run();
    }

    ARDUINO UNO|MEGA (Arduino Ethernet shield (W5100))

    Спойлер
    /*************************************************************
      This example shows how to use Arduino Ethernet shield (W5100)
      to connect your project to Blynk.
    
      NOTE: Pins 10, 11, 12 and 13 are reserved for Ethernet module.
            DON'T use them in your sketch directly!
    
      WARNING: If you have an SD card, you may need to disable it
            by setting pin 4 to HIGH. Read more here:
            https://www.arduino.cc/en/Main/ArduinoEthernetShield
    
      This example shows how you can process commands from player widget
    
      App dashboard setup:
        Music Player widget attached to V5
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <SPI.h>
    #include <Ethernet.h>
    #include <BlynkSimpleEthernet.h>
    
    #define W5100_CS  10
    #define SDCARD_CS 4
    
    BLYNK_WRITE(V5)
    {
      String action = param.asStr();
    
      if (action == "play") {
        // Do something
      }
      if (action == "stop") {
        // Do something
      }
      if (action == "next") {
        // Do something
      }
      if (action == "prev") {
        // Do something
      }
    
      Blynk.setProperty(V5, "label", action);
      Serial.print(action);
      Serial.println();
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      pinMode(SDCARD_CS, OUTPUT);
      digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
    
      Blynk.begin(BLYNK_AUTH_TOKEN);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(91,204,228,77), 8480);
    }
    
    void loop()
    {
      Blynk.run();
    }

     

    RTC

    ESP8266 WIFI

    Спойлер
    /*************************************************************
    
      Blynk can provide your device with time data, like an RTC.
      Please note that the accuracy of this method is up to several seconds.
    
      App dashboard setup:
        Value Display widget on V1
        Value Display widget on V2
    
      WARNING :
      For this example you'll need Time keeping library:
        https://github.com/PaulStoffregen/Time
    
      This code is based on an example from the Time library:
        https://github.com/PaulStoffregen/Time/blob/master/examples/TimeSerial/TimeSerial.ino
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
    #include <TimeLib.h>
    #include <WidgetRTC.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    BlynkTimer timer;
    
    WidgetRTC rtc;
    
    // Digital clock display of the time
    void clockDisplay()
    {
      // You can call hour(), minute(), ... at any time
      // Please see Time library examples for details
    
      String currentTime = String(hour()) + ":" + minute() + ":" + second();
      String currentDate = String(day()) + " " + month() + " " + year();
      Serial.print("Current time: ");
      Serial.print(currentTime);
      Serial.print(" ");
      Serial.print(currentDate);
      Serial.println();
    
      // Send time to the App
      Blynk.virtualWrite(V1, currentTime);
      // Send date to the App
      Blynk.virtualWrite(V2, currentDate);
    }
    
    BLYNK_CONNECTED() {
      // Synchronize time on connection
      rtc.begin();
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    
      // Other Time library functions can be used, like:
      //   timeStatus(), setSyncInterval(interval)...
      // Read more: http://www.pjrc.com/teensy/td_libs_Time.html
    
      setSyncInterval(10 * 60); // Sync interval in seconds (10 minutes)
    
      // Display digital clock every 10 seconds
      timer.setInterval(10000L, clockDisplay);
    }
    
    void loop()
    {
      Blynk.run();
      timer.run();
    }

    ESP32 WIFI

    Спойлер
    /*************************************************************
    
      Blynk can provide your device with time data, like an RTC.
      Please note that the accuracy of this method is up to several seconds.
    
      App dashboard setup:
        Value Display widget on V1
        Value Display widget on V2
    
      WARNING :
      For this example you'll need Time keeping library:
        https://github.com/PaulStoffregen/Time
    
      This code is based on an example from the Time library:
        https://github.com/PaulStoffregen/Time/blob/master/examples/TimeSerial/TimeSerial.ino
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <WiFi.h>
    #include <WiFiClient.h>
    #include <BlynkSimpleEsp32.h>
    #include <TimeLib.h>
    #include <WidgetRTC.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    BlynkTimer timer;
    
    WidgetRTC rtc;
    
    // Digital clock display of the time
    void clockDisplay()
    {
      // You can call hour(), minute(), ... at any time
      // Please see Time library examples for details
    
      String currentTime = String(hour()) + ":" + minute() + ":" + second();
      String currentDate = String(day()) + " " + month() + " " + year();
      Serial.print("Current time: ");
      Serial.print(currentTime);
      Serial.print(" ");
      Serial.print(currentDate);
      Serial.println();
    
      // Send time to the App
      Blynk.virtualWrite(V1, currentTime);
      // Send date to the App
      Blynk.virtualWrite(V2, currentDate);
    }
    
    BLYNK_CONNECTED() {
      // Synchronize time on connection
      rtc.begin();
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    
      // Other Time library functions can be used, like:
      //   timeStatus(), setSyncInterval(interval)...
      // Read more: http://www.pjrc.com/teensy/td_libs_Time.html
    
      setSyncInterval(10 * 60); // Sync interval in seconds (10 minutes)
    
      // Display digital clock every 10 seconds
      timer.setInterval(10000L, clockDisplay);
    }
    
    void loop()
    {
      Blynk.run();
      timer.run();
    }

    ARDUINO UNO|MEGA (Arduino Ethernet shield (W5100))

    Спойлер
    /*************************************************************
      This example shows how to use Arduino Ethernet shield (W5100)
      to connect your project to Blynk.
    
      NOTE: Pins 10, 11, 12 and 13 are reserved for Ethernet module.
            DON'T use them in your sketch directly!
    
      WARNING: If you have an SD card, you may need to disable it
            by setting pin 4 to HIGH. Read more here:
            https://www.arduino.cc/en/Main/ArduinoEthernetShield
    
      Blynk can provide your device with time data, like an RTC.
      Please note that the accuracy of this method is up to several seconds.
    
      App dashboard setup:
        Value Display widget on V1
        Value Display widget on V2
    
      WARNING :
      For this example you'll need Time keeping library:
        https://github.com/PaulStoffregen/Time
    
      This code is based on an example from the Time library:
        https://github.com/PaulStoffregen/Time/blob/master/examples/TimeSerial/TimeSerial.ino
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <SPI.h>
    #include <Ethernet.h>
    #include <BlynkSimpleEthernet.h>
    #include <TimeLib.h>
    #include <WidgetRTC.h>
    
    #define W5100_CS  10
    #define SDCARD_CS 4
    
    BlynkTimer timer;
    
    WidgetRTC rtc;
    
    // Digital clock display of the time
    void clockDisplay()
    {
      // You can call hour(), minute(), ... at any time
      // Please see Time library examples for details
    
      String currentTime = String(hour()) + ":" + minute() + ":" + second();
      String currentDate = String(day()) + " " + month() + " " + year();
      Serial.print("Current time: ");
      Serial.print(currentTime);
      Serial.print(" ");
      Serial.print(currentDate);
      Serial.println();
    
      // Send time to the App
      Blynk.virtualWrite(V1, currentTime);
      // Send date to the App
      Blynk.virtualWrite(V2, currentDate);
    }
    
    BLYNK_CONNECTED() {
      // Synchronize time on connection
      rtc.begin();
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      pinMode(SDCARD_CS, OUTPUT);
      digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
    
      Blynk.begin(BLYNK_AUTH_TOKEN);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(91,204,228,77), 8480);
    
      // Other Time library functions can be used, like:
      //   timeStatus(), setSyncInterval(interval)...
      // Read more: http://www.pjrc.com/teensy/td_libs_Time.html
    
      setSyncInterval(10 * 60); // Sync interval in seconds (10 minutes)
    
      // Display digital clock every 10 seconds
      timer.setInterval(10000L, clockDisplay);
    }
    
    void loop()
    {
      Blynk.run();
      timer.run();
    }

     

    RTC ADVANCED

    ESP8266 WIFI

    Спойлер
    /*************************************************************
    
      Blynk can provide your device with time data, like an RTC.
      Please note that the accuracy of this method is up to several seconds.
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    BlynkTimer timer;
    
    void requestTime() {
      Blynk.sendInternal("rtc", "sync");
    }
    
    BLYNK_WRITE(InternalPinRTC) {
      long t = param.asLong();
      Serial.print("Unix time: ");
      Serial.print(t);
      Serial.println();
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    
      timer.setInterval(10000L, requestTime);
    }
    
    void loop()
    {
      Blynk.run();
      timer.run();
    }

    ESP32 WIFI

    Спойлер
    /*************************************************************
    
      Blynk can provide your device with time data, like an RTC.
      Please note that the accuracy of this method is up to several seconds.
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <WiFi.h>
    #include <WiFiClient.h>
    #include <BlynkSimpleEsp32.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    BlynkTimer timer;
    
    void requestTime() {
      Blynk.sendInternal("rtc", "sync");
    }
    
    BLYNK_WRITE(InternalPinRTC) {
      long t = param.asLong();
      Serial.print("Unix time: ");
      Serial.print(t);
      Serial.println();
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8780);
    
      timer.setInterval(10000L, requestTime);
    }
    
    void loop()
    {
      Blynk.run();
      timer.run();
    }

    ARDUINO UNO|MEGA (Arduino Ethernet shield (W5100))

    Спойлер
    /*************************************************************
      This example shows how to use Arduino Ethernet shield (W5100)
      to connect your project to Blynk.
    
      NOTE: Pins 10, 11, 12 and 13 are reserved for Ethernet module.
            DON'T use them in your sketch directly!
    
      WARNING: If you have an SD card, you may need to disable it
            by setting pin 4 to HIGH. Read more here:
            https://www.arduino.cc/en/Main/ArduinoEthernetShield
    
      Blynk can provide your device with time data, like an RTC.
      Please note that the accuracy of this method is up to several seconds.
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <SPI.h>
    #include <Ethernet.h>
    #include <BlynkSimpleEthernet.h>
    
    #define W5100_CS  10
    #define SDCARD_CS 4
    
    BlynkTimer timer;
    
    void requestTime() {
      Blynk.sendInternal("rtc", "sync");
    }
    
    BLYNK_WRITE(InternalPinRTC) {
      long t = param.asLong();
      Serial.print("Unix time: ");
      Serial.print(t);
      Serial.println();
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      pinMode(SDCARD_CS, OUTPUT);
      digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
    
      Blynk.begin(BLYNK_AUTH_TOKEN);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(91,204,228,77), 8480);
    
      timer.setInterval(10000L, requestTime);
    }
    
    void loop()
    {
      Blynk.run();
      timer.run();
    }

     

    MENU

    ESP8266 WIFI

    Спойлер
    /*************************************************************
    
      You can send/receive any data using WidgetTerminal object.
    
      App dashboard setup:
        Terminal widget attached to Virtual Pin V1
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    // Attach virtual serial terminal to Virtual Pin V1
    WidgetTerminal terminal(V1);
    
    // You can send commands from Terminal to your hardware. Just use
    // the same Virtual Pin as your Terminal Widget
    BLYNK_WRITE(V1)
    {
    
      // if you type "Marco" into Terminal Widget - it will respond: "Polo:"
      if (String("Marco") == param.asStr()) {
        terminal.println("You said: 'Marco'") ;
        terminal.println("I said: 'Polo'") ;
      } else {
    
        // Send it back
        terminal.print("You said:");
        terminal.write(param.getBuffer(), param.getLength());
        terminal.println();
      }
    
      // Ensure everything is sent
      terminal.flush();
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    
      // Clear the terminal content
      terminal.clear();
    
      // This will print Blynk Software version to the Terminal Widget when
      // your hardware gets connected to Blynk Server
      terminal.println(F("Blynk v" BLYNK_VERSION ": Device started"));
      terminal.println(F("-------------"));
      terminal.println(F("Type 'Marco' and get a reply, or type"));
      terminal.println(F("anything else and get it printed back."));
      terminal.flush();
    }
    
    void loop()
    {
      Blynk.run();
    }

    ESP32 WIFI

    Спойлер
    /*************************************************************
    
      You can send/receive any data using WidgetTerminal object.
    
      App dashboard setup:
        Terminal widget attached to Virtual Pin V1
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <WiFi.h>
    #include <WiFiClient.h>
    #include <BlynkSimpleEsp32.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    // Attach virtual serial terminal to Virtual Pin V1
    WidgetTerminal terminal(V1);
    
    // You can send commands from Terminal to your hardware. Just use
    // the same Virtual Pin as your Terminal Widget
    BLYNK_WRITE(V1)
    {
    
      // if you type "Marco" into Terminal Widget - it will respond: "Polo:"
      if (String("Marco") == param.asStr()) {
        terminal.println("You said: 'Marco'") ;
        terminal.println("I said: 'Polo'") ;
      } else {
    
        // Send it back
        terminal.print("You said:");
        terminal.write(param.getBuffer(), param.getLength());
        terminal.println();
      }
    
      // Ensure everything is sent
      terminal.flush();
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    
      // Clear the terminal content
      terminal.clear();
    
      // This will print Blynk Software version to the Terminal Widget when
      // your hardware gets connected to Blynk Server
      terminal.println(F("Blynk v" BLYNK_VERSION ": Device started"));
      terminal.println(F("-------------"));
      terminal.println(F("Type 'Marco' and get a reply, or type"));
      terminal.println(F("anything else and get it printed back."));
      terminal.flush();
    }
    
    void loop()
    {
      Blynk.run();
    }

    ARDUINO UNO|MEGA (Arduino Ethernet shield (W5100))

    Спойлер
    /*************************************************************
      This example shows how to use Arduino Ethernet shield (W5100)
      to connect your project to Blynk.
    
      NOTE: Pins 10, 11, 12 and 13 are reserved for Ethernet module.
            DON'T use them in your sketch directly!
    
      WARNING: If you have an SD card, you may need to disable it
            by setting pin 4 to HIGH. Read more here:
            https://www.arduino.cc/en/Main/ArduinoEthernetShield
    
      You can send/receive any data using WidgetTerminal object.
    
      App dashboard setup:
        Terminal widget attached to Virtual Pin V1
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <SPI.h>
    #include <Ethernet.h>
    #include <BlynkSimpleEthernet.h>
    
    #define W5100_CS  10
    #define SDCARD_CS 4
    
    // Attach virtual serial terminal to Virtual Pin V1
    WidgetTerminal terminal(V1);
    
    // You can send commands from Terminal to your hardware. Just use
    // the same Virtual Pin as your Terminal Widget
    BLYNK_WRITE(V1)
    {
    
      // if you type "Marco" into Terminal Widget - it will respond: "Polo:"
      if (String("Marco") == param.asStr()) {
        terminal.println("You said: 'Marco'") ;
        terminal.println("I said: 'Polo'") ;
      } else {
    
        // Send it back
        terminal.print("You said:");
        terminal.write(param.getBuffer(), param.getLength());
        terminal.println();
      }
    
      // Ensure everything is sent
      terminal.flush();
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      pinMode(SDCARD_CS, OUTPUT);
      digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
    
      Blynk.begin(BLYNK_AUTH_TOKEN);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(91,204,228,77), 8480);
    
      // Clear the terminal content
      terminal.clear();
    
      // This will print Blynk Software version to the Terminal Widget when
      // your hardware gets connected to Blynk Server
      terminal.println(F("Blynk v" BLYNK_VERSION ": Device started"));
      terminal.println(F("-------------"));
      terminal.println(F("Type 'Marco' and get a reply, or type"));
      terminal.println(F("anything else and get it printed back."));
      terminal.flush();
    }
    
    void loop()
    {
      Blynk.run();
    }

     

    SIMPLE TIME INPUT

    ESP8266 WIFI

    Спойлер
    /*************************************************************
    
      App dashboard setup:
        Time Input widget on V1 with only start time option.
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    BLYNK_WRITE(V1) {
      long startTimeInSecs = param[0].asLong();
      Serial.println(startTimeInSecs);
      Serial.println();
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    }
    
    void loop()
    {
      Blynk.run();
    }

    ESP32 WIFI

    Спойлер
    /*************************************************************
    
      App dashboard setup:
        Time Input widget on V1 with only start time option.
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <WiFi.h>
    #include <WiFiClient.h>
    #include <BlynkSimpleEsp32.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    BLYNK_WRITE(V1) {
      long startTimeInSecs = param[0].asLong();
      Serial.println(startTimeInSecs);
      Serial.println();
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    }
    
    void loop()
    {
      Blynk.run();
    }

    ARDUINO UNO|MEGA (Arduino Ethernet shield (W5100))

    Спойлер
    /*************************************************************
      This example shows how to use Arduino Ethernet shield (W5100)
      to connect your project to Blynk.
    
      NOTE: Pins 10, 11, 12 and 13 are reserved for Ethernet module.
            DON'T use them in your sketch directly!
    
      WARNING: If you have an SD card, you may need to disable it
            by setting pin 4 to HIGH. Read more here:
            https://www.arduino.cc/en/Main/ArduinoEthernetShield
    
      App dashboard setup:
        Time Input widget on V1 with only start time option.
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <SPI.h>
    #include <Ethernet.h>
    #include <BlynkSimpleEthernet.h>
    
    #define W5100_CS  10
    #define SDCARD_CS 4
    
    BLYNK_WRITE(V1) {
      long startTimeInSecs = param[0].asLong();
      Serial.println(startTimeInSecs);
      Serial.println();
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      pinMode(SDCARD_CS, OUTPUT);
      digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
    
      Blynk.begin(BLYNK_AUTH_TOKEN);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(91,204,228,77), 8480);
    }
    
    void loop()
    {
      Blynk.run();
    }

     

    ADVANCED TIME INPUT

    ESP8266 WIFI

    Спойлер
    /*************************************************************
    
      App dashboard setup:
        Time Input widget on V1.
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    BLYNK_WRITE(V1) {
      TimeInputParam t(param);
    
      // Process start time
    
      if (t.hasStartTime())
      {
        Serial.println(String("Start: ") +
                       t.getStartHour() + ":" +
                       t.getStartMinute() + ":" +
                       t.getStartSecond());
      }
      else if (t.isStartSunrise())
      {
        Serial.println("Start at sunrise");
      }
      else if (t.isStartSunset())
      {
        Serial.println("Start at sunset");
      }
      else
      {
        // Do nothing
      }
    
      // Process stop time
    
      if (t.hasStopTime())
      {
        Serial.println(String("Stop: ") +
                       t.getStopHour() + ":" +
                       t.getStopMinute() + ":" +
                       t.getStopSecond());
      }
      else if (t.isStopSunrise())
      {
        Serial.println("Stop at sunrise");
      }
      else if (t.isStopSunset())
      {
        Serial.println("Stop at sunset");
      }
      else
      {
        // Do nothing: no stop time was set
      }
    
      // Process timezone
      // Timezone is already added to start/stop time
    
      Serial.println(String("Time zone: ") + t.getTZ());
    
      // Get timezone offset (in seconds)
      Serial.println(String("Time zone offset: ") + t.getTZ_Offset());
    
      // Process weekdays (1. Mon, 2. Tue, 3. Wed, ...)
    
      for (int i = 1; i <= 7; i++) {
        if (t.isWeekdaySelected(i)) {
          Serial.println(String("Day ") + i + " is selected");
        }
      }
    
      Serial.println();
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    }
    
    void loop()
    {
      Blynk.run();
    }

    ESP32 WIFI

    Спойлер
    /*************************************************************
    
      App dashboard setup:
        Time Input widget on V1.
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <WiFi.h>
    #include <WiFiClient.h>
    #include <BlynkSimpleEsp32.h>
    
    // Your WiFi credentials.
    // Set password to "" for open networks.
    char ssid[] = "YourNetworkName";
    char pass[] = "YourPassword";
    
    BLYNK_WRITE(V1) {
      TimeInputParam t(param);
    
      // Process start time
    
      if (t.hasStartTime())
      {
        Serial.println(String("Start: ") +
                       t.getStartHour() + ":" +
                       t.getStartMinute() + ":" +
                       t.getStartSecond());
      }
      else if (t.isStartSunrise())
      {
        Serial.println("Start at sunrise");
      }
      else if (t.isStartSunset())
      {
        Serial.println("Start at sunset");
      }
      else
      {
        // Do nothing
      }
    
      // Process stop time
    
      if (t.hasStopTime())
      {
        Serial.println(String("Stop: ") +
                       t.getStopHour() + ":" +
                       t.getStopMinute() + ":" +
                       t.getStopSecond());
      }
      else if (t.isStopSunrise())
      {
        Serial.println("Stop at sunrise");
      }
      else if (t.isStopSunset())
      {
        Serial.println("Stop at sunset");
      }
      else
      {
        // Do nothing: no stop time was set
      }
    
      // Process timezone
      // Timezone is already added to start/stop time
    
      Serial.println(String("Time zone: ") + t.getTZ());
    
      // Get timezone offset (in seconds)
      Serial.println(String("Time zone offset: ") + t.getTZ_Offset());
    
      // Process weekdays (1. Mon, 2. Tue, 3. Wed, ...)
    
      for (int i = 1; i <= 7; i++) {
        if (t.isWeekdaySelected(i)) {
          Serial.println(String("Day ") + i + " is selected");
        }
      }
    
      Serial.println();
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(91,204,228,77), 8480);
    }
    
    void loop()
    {
      Blynk.run();
    }

    ARDUINO UNO|MEGA (Arduino Ethernet shield (W5100))

    Спойлер
    /*************************************************************
      This example shows how to use Arduino Ethernet shield (W5100)
      to connect your project to Blynk.
    
      NOTE: Pins 10, 11, 12 and 13 are reserved for Ethernet module.
            DON'T use them in your sketch directly!
    
      WARNING: If you have an SD card, you may need to disable it
            by setting pin 4 to HIGH. Read more here:
            https://www.arduino.cc/en/Main/ArduinoEthernetShield
    
      App dashboard setup:
        Time Input widget on V1.
     *************************************************************/
    
    /* Fill-in information from Blynk Device Info here */
    #define BLYNK_TEMPLATE_ID           "TMPxxxxxx"
    #define BLYNK_TEMPLATE_NAME         "Device"
    #define BLYNK_AUTH_TOKEN            "YourAuthToken"
    
    /* Comment this out to disable prints and save space */
    #define BLYNK_PRINT Serial
    
    
    #include <SPI.h>
    #include <Ethernet.h>
    #include <BlynkSimpleEthernet.h>
    
    #define W5100_CS  10
    #define SDCARD_CS 4
    
    BLYNK_WRITE(V1) {
      TimeInputParam t(param);
    
      // Process start time
    
      if (t.hasStartTime())
      {
        Serial.println(String("Start: ") +
                       t.getStartHour() + ":" +
                       t.getStartMinute() + ":" +
                       t.getStartSecond());
      }
      else if (t.isStartSunrise())
      {
        Serial.println("Start at sunrise");
      }
      else if (t.isStartSunset())
      {
        Serial.println("Start at sunset");
      }
      else
      {
        // Do nothing
      }
    
      // Process stop time
    
      if (t.hasStopTime())
      {
        Serial.println(String("Stop: ") +
                       t.getStopHour() + ":" +
                       t.getStopMinute() + ":" +
                       t.getStopSecond());
      }
      else if (t.isStopSunrise())
      {
        Serial.println("Stop at sunrise");
      }
      else if (t.isStopSunset())
      {
        Serial.println("Stop at sunset");
      }
      else
      {
        // Do nothing: no stop time was set
      }
    
      // Process timezone
      // Timezone is already added to start/stop time
    
      Serial.println(String("Time zone: ") + t.getTZ());
    
      // Get timezone offset (in seconds)
      Serial.println(String("Time zone offset: ") + t.getTZ_Offset());
    
      // Process weekdays (1. Mon, 2. Tue, 3. Wed, ...)
    
      for (int i = 1; i <= 7; i++) {
        if (t.isWeekdaySelected(i)) {
          Serial.println(String("Day ") + i + " is selected");
        }
      }
    
      Serial.println();
    }
    
    void setup()
    {
      // Debug console
      Serial.begin(115200);
    
      pinMode(SDCARD_CS, OUTPUT);
      digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
    
      Blynk.begin(BLYNK_AUTH_TOKEN);
      // You can also specify server:
      //Blynk.begin(BLYNK_AUTH_TOKEN, "blynk.cloud", 80);
      //Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(192,168,1,100), 8080);
      Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(91,204,228,77), 8480);
    }
    
    void loop()
    {
      Blynk.run();
    }

     

×
×
  • Create New...

Important Information