safwan092

Untitled

Dec 8th, 2018
194
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define PUMP_PIN D2
  2. #define BLYNK_PRINT Serial
  3. #include <ESP8266WiFi.h>
  4. #include <BlynkSimpleEsp8266.h>
  5. #include <SimpleTimer.h>
  6. char auth[] = "bfd3ac0104f24a9884ac843db6be012a";
  7. char ssid[] = "20012";
  8. char pass[] = "12345678";
  9.  
  10. long dt=0;
  11. int pinValue;
  12. SimpleTimer timer;
  13. void turnOn(){digitalWrite(PUMP_PIN,1);Blynk.virtualWrite(V0, 1);}
  14. void turnOff(){digitalWrite(PUMP_PIN,0);Blynk.virtualWrite(V0, 0);}
  15.  
  16. BLYNK_WRITE(V0)
  17. {
  18. int pinValue0 = param.asInt();
  19. Serial.print("V0 Slider value is: ");
  20. Serial.println(pinValue0);
  21. if(pinValue0 && pinValue>0){
  22. turnOn();
  23. dt=pinValue*29000;
  24. timer.setTimeout(dt, turnOff);
  25. }
  26. }
  27.  
  28. BLYNK_WRITE(V1)
  29. {
  30. pinValue = param.asInt();
  31. Serial.print("V1 Slider value is: ");
  32. Serial.println(pinValue);
  33. }
  34.  
  35. void setup()
  36. {
  37. Serial.begin(9600);
  38. Blynk.begin(auth, ssid, pass);
  39. }
  40.  
  41. void loop()
  42. {
  43. timer.run();
  44. Blynk.run();
  45. }
RAW Paste Data