Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Migająca dioda wirtualna w aplikacji Blynk sterowana z Wemos D1 mini
/*************************************************************
You can use predefined rules on application side.
Project setup in the Blynk app:
Eventor widget with next rules :
a) When V0 is equal to 1, set V1 to 255;
b) When V0 is equal to 0, set V1 to 0;
Led widget on V1 pin
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "";
char pass[] = "";
BlynkTimer timer;
boolean flag = true;
void sendFlagToServer() {
if (flag) {
Blynk.virtualWrite(V0, 1);
} else {
Blynk.virtualWrite(V0, 0);
}
flag = !flag;
}
BLYNK_WRITE(V1) {
//here you'll get 0 or 255
int ledValue = param.asInt();
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
// Setup a function to be called every second
timer.setInterval(1000L, sendFlagToServer);
}
void loop()
{
Blynk.run();
timer.run();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment