krzysp

BLYNK grzejnik pompa.h

Jan 1st, 2023
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Arduino 1.83 KB | Source Code | 0 0
  1.  
  2. #define przek   0
  3.  
  4. void pompasetup() {
  5.   pinMode(przek, OUTPUT); //LED na module
  6.   digitalWrite(przek, HIGH);
  7. }
  8.  
  9. int t_on = 10;
  10. int t_off = 10;
  11. int stan_przek = 1;  //0 włączony 1 wyłączony 2 regulowany czas załączenia
  12.  
  13. void speed_led(){
  14.   if (stan_przek == 1) akcja.updateInterval(2, 2000);
  15.   if (stan_przek == 0) akcja.updateInterval(2, 1000);
  16.   if (stan_przek == 2) akcja.updateInterval(2, 500);
  17. }
  18. void wys_t() {
  19.   Blynk.virtualWrite(V2, t_on);
  20.   Blynk.virtualWrite(V3, t_off);
  21. }
  22.  
  23. int on_off = 0;    // stan włącznika głównego
  24. int on_off_t = 0;  // stan włącznika regulacji czasu
  25.  
  26. BLYNK_WRITE(V10) {
  27.   if (param.asInt()) on_off = 1;
  28.   else on_off = 0;
  29.  
  30.   if (on_off) {
  31.     if (on_off_t) stan_przek = 2;
  32.     else stan_przek = 0;
  33.   } else stan_przek = 1;
  34.  
  35.   if (param.asInt()) digitalWrite(przek, LOW);
  36.   else digitalWrite(przek, HIGH);
  37.   Blynk.virtualWrite(V1, stan_przek);
  38.   wys_t();
  39.  speed_led();  
  40. }
  41.  
  42. int t_on_mem = 10;
  43. int t_off_mem = 10;
  44. BLYNK_WRITE(V11) {
  45.   on_off_t = (param.asInt());
  46.   if (on_off_t) t_on = t_on_mem;
  47.  // else t_on = 0;
  48.   if (on_off_t) t_off = t_off_mem;
  49.  // else t_off = 0;
  50.   if (on_off_t)
  51.     ;
  52.   else stan_przek = !on_off;
  53.   Blynk.virtualWrite(V1, stan_przek);
  54.   wys_t();
  55. }
  56.  
  57. BLYNK_WRITE(V12) {
  58. t_on_mem = (param.asInt());
  59. t_on = t_on_mem;
  60.  wys_t();
  61. }
  62. BLYNK_WRITE(V13) {
  63. t_off_mem = (param.asInt());
  64. t_off = t_off_mem;
  65.  wys_t();
  66. }
  67. void czas_timer() {
  68.  
  69.   if (stan_przek > 1) {
  70.     if (stan_przek == 2) {
  71.       t_on = t_on - 1;
  72.       if (t_on < 1) {
  73.         t_off = t_off_mem + 1;
  74.         digitalWrite(przek, HIGH);
  75.         stan_przek = 3;
  76.       }
  77.     }
  78.     if (stan_przek == 3) {
  79.       t_off = t_off - 1;
  80.       if (t_off < 1) {
  81.         t_on = t_on_mem;
  82.         digitalWrite(przek, LOW);
  83.         stan_przek = 2;
  84.       }
  85.     }
  86.   }
  87.    wys_t();
  88. }
  89.  
Tags: BLYNK
Advertisement
Add Comment
Please, Sign In to add comment