-
-
Save yarogniew/c57776307d6a6b0e8f4e55300a48ca24 to your computer and use it in GitHub Desktop.
Migająca dioda wirtualna w aplikacji Blynk sterowana z Wemos D1 mini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************************************* | |
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