Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.79 KB | None | 0 0
  1. #define BLYNK_PRINT Serial
  2.  
  3. #include <ESP8266WiFi.h>
  4. #include <BlynkSimpleEsp8266.h>
  5.  
  6. char auth[] = "9cc73cbad1334a7b9a0a78022ff8b4e1";
  7.  
  8. char ssid[] = "Hippies-Box";
  9. char pass[] = "1608195516021964";
  10.  
  11. // GPIO12 = D6 = Ansteuerung Relais LOGO Licht Garten
  12. // GPIO1 = TX = Rückmeldung LOGO Licht Garten
  13. // GPIO2 = D4 = Ansteuerung Relais LOGO Laterne
  14. // GPIO3 = RX = Rückmeldung LOGO Laterne
  15. // GPIO4 = D2 = Ansteuerung Relais LOGO Party
  16. // GPIO5 = D1 = Rückmeldung LOGO Party
  17. // GPIO14 = D5 = Ansteuerung Relais 4
  18. // GPIO13 = D7 = Rückmeldung Relais 4
  19.  
  20. const int btnPin1 = 12; // Relais Garten
  21. const int btnPin2 = 1; // Rückmeldung Garten
  22. const int btnPin3 = 2; // Relais Laterne
  23. const int btnPin4 = 3; // Rückmeldung Laterne
  24. const int btnPin5 = 4; // Relais Party
  25. const int btnPin6 = 5; // Rückmeldung Party
  26. const int btnPin7 = 14; // Relais 4
  27. const int btnPin8 = 13; // Rückmeldung Relais 4
  28.  
  29. // V1 = Rückmeldung LOGO Licht Garten
  30. // V2 = Rückmeldung LOGO Laterne
  31. // V3 = Rückmeldung LOGO Party
  32. // V4 = Rückmeldung Relais 4
  33.  
  34. WidgetLED led1(V1);
  35. WidgetLED led2(V2);
  36. WidgetLED led3(V3);
  37. WidgetLED led4(V4);
  38.  
  39. BlynkTimer timer;
  40.  
  41.  
  42. boolean btnState1 = false;
  43. void buttonLedWidget1()
  44.  
  45. {
  46. boolean isPressed = (digitalRead(btnPin2) == LOW);
  47.  
  48. if (isPressed != btnState1) {
  49. if (isPressed) {
  50. led1.on();
  51. } else {
  52. led1.off();
  53. }
  54. btnState1 = isPressed;
  55. }
  56. }
  57.  
  58. boolean btnState2 = false;
  59. void buttonLedWidget2()
  60.  
  61. {
  62. boolean isPressed = (digitalRead(btnPin4) == LOW);
  63.  
  64. if (isPressed != btnState2) {
  65. if (isPressed) {
  66. led2.on();
  67. } else {
  68. led2.off();
  69. }
  70. btnState2 = isPressed;
  71. }
  72. }
  73.  
  74. boolean btnState3 = false;
  75. void buttonLedWidget3()
  76.  
  77. {
  78. boolean isPressed = (digitalRead(btnPin6) == LOW);
  79.  
  80. if (isPressed != btnState3) {
  81. if (isPressed) {
  82. led3.on();
  83. } else {
  84. led3.off();
  85. }
  86. btnState3 = isPressed;
  87. }
  88. }
  89.  
  90. boolean btnState4 = false;
  91. void buttonLedWidget4()
  92.  
  93. {
  94. boolean isPressed = (digitalRead(btnPin8) == LOW);
  95.  
  96. if (isPressed != btnState4) {
  97. if (isPressed) {
  98. led4.on();
  99. } else {
  100. led4.off();
  101. }
  102. btnState4 = isPressed;
  103. }
  104. }
  105.  
  106. void setup()
  107. {
  108. // Debug console
  109. Serial.begin(9600);
  110.  
  111. Blynk.begin(auth, ssid, pass);
  112.  
  113.  
  114. pinMode(btnPin1, OUTPUT);
  115. pinMode(btnPin3, OUTPUT);
  116. pinMode(btnPin5, OUTPUT);
  117. pinMode(btnPin7, OUTPUT);
  118.  
  119. pinMode(btnPin2, INPUT_PULLUP);
  120. pinMode(btnPin4, INPUT_PULLUP);
  121. pinMode(btnPin6, INPUT_PULLUP);
  122. pinMode(btnPin8, INPUT_PULLUP);
  123.  
  124. timer.setInterval(1000L, buttonLedWidget1);
  125. timer.setInterval(1000L, buttonLedWidget2);
  126. timer.setInterval(1000L, buttonLedWidget3);
  127. timer.setInterval(1000L, buttonLedWidget4);
  128. }
  129.  
  130. void loop()
  131. {
  132. Blynk.run();
  133. timer.run();
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement