Advertisement
Krzyspx

BLYNK widget LED

Oct 21st, 2017
701
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.79 KB | None | 0 0
  1. //modul D1 MINI
  2.  
  3. char ssid[] = "aaaaaaaaaaaa";
  4. char pass[] = "bbbbbbbbbbbb";
  5. #define BLYNK_PRINT Serial
  6. #include <ESP8266WiFi.h>
  7. #include <BlynkSimpleEsp8266.h>
  8. char auth[] = "b483bee9610e47c6ba259529cf12eea0";
  9.  
  10. #define _RED            "#FF0000"
  11. #define _GREEN          "#00FF00"
  12. #define _BLUE           "#0000F0"
  13.  
  14. #include <Timers.h> //  my favorite timer
  15. Timers <6> akcja; //
  16.  
  17. int wskLED = 0;
  18. WidgetLED led10(V10);
  19. void miganievLED10()
  20. { wskLED = !wskLED ;
  21.   if (wskLED == 0)led10.off(); else led10.on();
  22. }
  23.  
  24. void miganievLED11()
  25. { if (wskLED == 0)  Blynk.virtualWrite(V11, 0); else Blynk.virtualWrite(V11, 255);
  26. }
  27.  
  28. int i = 0;
  29. void miganievLED12()
  30. {
  31.   i = i + 50;  if (i > 255)i = 0;
  32.   Blynk.virtualWrite(V12, i);
  33.   Blynk.setProperty(V12, "label", i);
  34. }
  35.  
  36. void miganievLED13()
  37. { if (wskLED == 0)  Blynk.setProperty(V13, "color", _RED); else Blynk.setProperty(V13, "color", _GREEN);
  38. }
  39.  
  40. BLYNK_WRITE(V14) //set czasu off
  41. {
  42.   int LED14 = param.asInt();
  43.   if (LED14)  Serial.println("LED14 on"); else Serial.println("LED14 off");
  44. }
  45.  
  46. void setup()
  47. {
  48.   Serial.begin(115200);
  49.   delay(100);
  50.   Serial.println();
  51.   Serial.println(F(__FILE__));  //BLYNK .4.8 Arduino IDE.cc 1.8.3
  52.  
  53.   akcja.attach(0, 1000, timer1sek); //  1 sek1
  54.  
  55.   Blynk.begin(auth, ssid, pass, IPAddress(192, 168, 2, 20));
  56.   Blynk.virtualWrite(V13, 255);
  57. }
  58.  
  59. void loop()
  60. {
  61.   akcja.process(); // timer
  62.   Blynk.run();
  63. }
  64.  
  65. WidgetLED led1(V0);
  66. int wskrunAr = 0;
  67. void miganievLED() //miganie vLED dla kontroli połączenia z modułem
  68. {
  69.   wskrunAr = !wskrunAr ;
  70.   if (wskrunAr == 0)led1.off(); else led1.on();
  71. }
  72. void timer1sek() { //różne rzeczy wykonywane cyklicznie
  73.   miganievLED(); //wskaźnik vLED działania komunikacji
  74.  
  75.   miganievLED10();
  76.   miganievLED11();
  77.   miganievLED12();
  78.   miganievLED13();
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement