krzysp

virtuino grzejnik blok program.h

Jan 2nd, 2023
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Arduino 2.55 KB | Source Code | 0 0
  1.  
  2. #define przek   0
  3. #define led_wew 2
  4.  
  5. int V1_Value = 0;
  6. int V2_Value = 0;
  7. int V3_Value = 0;
  8. int V4_Value = 0;
  9.  
  10. int t_on = 10;
  11. int t_off = 10;
  12. int stan_przek = 1;  //0 włączony 1 wyłączony 2 regulowany czas załączenia
  13.  
  14. void speed_led() {
  15.   if (stan_przek == 1) akcja.updateInterval(0, 2000);
  16.   if (stan_przek == 0) akcja.updateInterval(0, 1000);
  17.   if (stan_przek == 2) akcja.updateInterval(0, 500);
  18. }
  19. void wys_t() {
  20.  
  21.   V7 = String(t_on);
  22.   V8 = String(t_off);
  23. }
  24. int on_off = 0;    // stan włącznika głównego
  25. int on_off_t = 0;  // stan włącznika regulacji czasu
  26.  
  27.  
  28. void Read_V1(String value_Text) {
  29.   V1_Value = value_Text.toInt();
  30.   // Serial.println("V1=" + value_Text);
  31.  
  32.   if (V1_Value) on_off = 1;
  33.   else on_off = 0;
  34.  
  35.   if (on_off) {
  36.     if (on_off_t) stan_przek = 2;
  37.     else stan_przek = 0;
  38.   } else stan_przek = 1;
  39.  
  40.   digitalWrite(przek, V1_Value);
  41.   V6 = String(stan_przek);
  42.   wys_t();
  43.   speed_led();
  44. }
  45. int t_on_mem = 10;
  46. int t_off_mem = 10;
  47.  
  48. void Read_V2(String value_Text) {
  49.   V2_Value = value_Text.toInt();
  50.   // Serial.println("V2=" + value_Text);
  51.  
  52.   on_off_t = V2_Value;
  53.   if (on_off_t) t_on = t_on_mem;
  54.   // else t_on = 0;
  55.   if (on_off_t) t_off = t_off_mem;
  56.   // else t_off = 0;
  57.   if (on_off_t)
  58.     ;
  59.   else stan_przek = !on_off;
  60.   V6 = String(stan_przek);
  61.   wys_t();
  62. }
  63.  
  64. void Read_V3(String value_Text) {
  65.   V3_Value = value_Text.toInt();
  66.   t_on_mem = V3_Value;
  67.   t_on = t_on_mem;
  68.   wys_t();
  69.  
  70.   //Serial.println("V3=" + value_Text);
  71. }
  72.  
  73. void Read_V4(String value_Text) {
  74.   V4_Value = value_Text.toInt();
  75.   t_off_mem = V4_Value;
  76.   t_off = t_off_mem;
  77.   wys_t();
  78.  
  79.   // Serial.println("V4=" + value_Text);
  80. }
  81.  
  82. void p_setup() {
  83.   pinMode(led_wew, OUTPUT);   //LED na module
  84.   digitalWrite(led_wew, HIGH);
  85.   pinMode(przek, OUTPUT); //pin przekaźnika
  86.   digitalWrite(przek, HIGH);
  87. }
  88. // This is the value that you want to send to virtuino APP
  89. int a = 0;
  90. void LED_timer() {
  91.   a = !a;
  92.   digitalWrite(led_wew, a);
  93. }
  94. int b = 0;
  95. void vLED_timer() {
  96.   V0 = String(b);             //LED in virtuino
  97.   b = !b;
  98. }
  99. void czas_timer() {
  100.   if (stan_przek > 1) {
  101.     if (stan_przek == 2) {
  102.       t_on = t_on - 1;
  103.       if (t_on < 1) {
  104.         t_off = t_off_mem + 1;
  105.         digitalWrite(przek, HIGH);
  106.         stan_przek = 3;
  107.       }
  108.     }
  109.     if (stan_przek == 3) {
  110.       t_off = t_off - 1;
  111.       if (t_off < 1) {
  112.         t_on = t_on_mem;
  113.         digitalWrite(przek, LOW);
  114.         stan_przek = 2;
  115.       }
  116.     }
  117.   }
  118.   wys_t();
  119. }
  120.  
  121.  
  122. void program_grzalka() {
  123.  
  124.   //my program tu akurat nic nie ma
  125. }
Tags: virtuino
Advertisement
Add Comment
Please, Sign In to add comment