Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //links with Blynk Libaries for NodeMCU
- #define BLYNK_PRINT Serial
- #include <ESP8266WiFi.h>
- #include <BlynkSimpleEsp8266.h>
- //Authentication
- char auth[] = "TOKEN"; //Your blynk token
- char ssid[] = "SSID"; //Your wifi SSID
- char pass[] = "PASS"; //Your wifi password
- //On startup
- void setup()
- {
- Serial.begin(9600); //starting the Debug com (Open it by clicking on Tools -> Serial Monitor)
- Blynk.begin(auth, ssid, pass); //Authentication with Blynk
- pinMode (D1, OUTPUT); //Enables Pin D1
- digitalWrite(D1, !digitalRead(D1)); //Sets state of Pin D1 to the opposite on start *Remove if Relay is on, on start*
- }
- //Turn on script
- BLYNK_WRITE(V1) { //Start of Script
- if (param.asInt()==1){ //Checks if Virtual port V1 is active, and if it is, it will run the script
- digitalWrite(D1, LOW); //Sets the state of port D1 to LOW
- delay(300); //Delay for 3 miliseconds
- digitalWrite(D1, HIGH); //Sets the state of port D1 to HIGH
- Blynk.virtualWrite(V1, LOW); //Sets Virtual port V1 to be disabled
- } //end of "if true" script
- } //End of script
- //Force turn off script
- BLYNK_WRITE(V2) { //Start of Script
- if (param.asInt()==1){ //Checks if Virtual port V2 is active, and if it is, it will run the script
- digitalWrite(D1, LOW); //Sets the state of port D1 to LOW
- delay(6000); //Delay for 3 miliseconds
- digitalWrite(D1, HIGH); //Sets the state of port D1 to HIGH
- Blynk.virtualWrite(V2, LOW); //Sets Virtual port V2 to be disabled
- } //end of "if true" script
- } //End of script
- //When running
- void loop()
- {
- Blynk.run(); //Start blynk connection
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement