krzysp

grzałka virtuino IoT blok piny.h

Jan 10th, 2023
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Arduino 1.98 KB | Source Code | 0 0
  1. #define monitor_on 1
  2. #define monitor_off 0
  3. int monitor_stan = monitor_on;  // wyłączanie seriala - np dla ESP01
  4.  
  5. //====== predefinicje funkcji z innych bloków programu
  6.  
  7. void pin1_rec(String value);
  8. void pin2_rec(String value);
  9. void pin3_rec(String value);
  10. void pin4_rec(String value);
  11.  
  12. bool sendValue(const char* tag, String value);
  13.  
  14. //======= deklaracje wartości początkowych
  15. int pin0_lastValue = 0;
  16. int pin6_lastValue = 0;
  17. int pin7_lastValue = 0;
  18. int pin8_lastValue = 0;
  19.  
  20. // deklaracje pinów łączących ESP i APP
  21. // V0 do V9 app --> esp,
  22. const char* pin0 = "V0";         // tag for digital input
  23. const char* pin1 = "V1";         // tag for digital input
  24. const char* pin2 = "V2";         // tag for digital input
  25. const char* pin3 = "V3";         // tag for digital input
  26. const char* pin4 = "V4";         // tag for digital o
  27. const char* pin5 = "V5";         // tag for digital input
  28.  
  29. const char* pin6 = "V6";         // tag for output
  30. const char* pin7 = "V7";        //tag for output
  31. const char* pin8 = "V8";     // tag for output
  32. const char* pin11 = "V11";     // tag for output
  33. const char* pin12 = "V12";  // tag for output
  34.  
  35. //===================================================== sendPinStatus
  36. // It is called every time a new client is connected.
  37. // The void informs Virtuino app about the current pin states and variable values.
  38.  
  39. void sendPinsStatus() {
  40.   sendValue(pin0, String(pin0_lastValue));
  41.   sendValue(pin6, String(pin6_lastValue));
  42.   sendValue(pin7, String(pin7_lastValue));
  43.   sendValue(pin8, String(pin8_lastValue));
  44. }
  45.  
  46.  
  47.  
  48. //===================================================== onValueReceived
  49. // It is called every time a new value received  - add ---> esp
  50. void onValueReceived(String tag, String value) {
  51.   if (monitor_stan = monitor_on)  Serial.println("Received: tag=" + tag + "  value=" + value);
  52.   if (tag == "V1") pin1_rec(value);
  53.   if (tag == "V2") pin2_rec(value);
  54.   if (tag == "V3") pin3_rec(value);
  55.   if (tag == "V4") pin4_rec(value);
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment