Advertisement
Guest User

Untitled

a guest
May 20th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.14 KB | None | 0 0
  1.  
  2.  
  3. /*
  4.  * Sensore temperatura frigo
  5.  * Condizionamento:   0  -   5 [V]
  6.  *                  -50  - 100 [°C]
  7.  */
  8. #define s_t_frigo A0  
  9.  
  10. /*
  11.  * Sensore temperatura rosticceria
  12.  * Condizionamento:   0  -   5 [V]
  13.  *                  -50  - 100 [°C]
  14.  */
  15. #define s_t_rost A1
  16.  
  17. /*
  18.  * Sensore temperatura corsie
  19.  * Condizionamento:   0  -   5 [V]
  20.  *                  -50  - 100 [°C]
  21.  */
  22. #define s_t_corsie A2
  23.  
  24. /*
  25.  * Sensore umidità corsie
  26.  * Nessun condizionamento
  27.  *                   1,5 -   4 [V]
  28.  *                    0  - 100 [%]
  29.  */
  30. #define s_h_corsie A3
  31.  
  32. /*
  33.  * Sensore luminosità corsie
  34.  * Condizionamento
  35.  *                   0 -    5 [V]
  36.  *                  10 - 1000 [lux]
  37.  */
  38. #define s_l_corsie A4
  39.  
  40.  
  41. /* Pompa di raffreddamento frigo */
  42. #define a_frigo 2
  43.  
  44. /* Resitenza riscaldamento rosticceria */
  45. #define a_rost 3
  46.  
  47. /* Condizionatore corsie*/
  48. #define a_t_corsie 4
  49.  
  50. /* umidificatore*/
  51. #define a_h_corsie 5
  52.  
  53. /* Neon supplementari*/
  54. #define neon 5
  55.  
  56. int t_frigo = 0;
  57. int t_rost = 0;
  58. int t_corsie = 0;
  59. int h_corsie = 0;
  60. int l_corsie = 0;
  61.  
  62. void setup() {
  63.   pinMode(a_frigo,OUTPUT);
  64.   pinMode(a_rost,OUTPUT);
  65.   pinMode(a_t_corsie,OUTPUT);
  66.   pinMode(a_h_corsie,OUTPUT);
  67.   pinMode(neon,OUTPUT);
  68. }
  69.  
  70. void loop() {
  71.   if(millis() % 1800000 == 0){ //Acquisizione dati ogni mezz'ora
  72.     t_frigo = map(analogRead(s_t_frigo), 0, 1023, -50, 100);
  73.     t_rost = map(analogRead(s_t_rost), 0, 1023, -50, 100);
  74.     t_corsie = map(analogRead(s_t_corsie), 0, 1023, -50, 100);
  75.     h_corsie = map(analogRead(s_h_corsie), 307, 819, 0, 100);
  76.     l_corsie = map(analogRead(s_l_corsie), 0, 1023, 10, 1000);
  77.   }
  78.  
  79.   if(t_frigo > -20) digitalWrite(a_frigo, HIGH);
  80.   else digitalWrite(a_frigo, LOW);
  81.  
  82.   if(t_rost < 40) digitalWrite(a_rost, HIGH);
  83.   else digitalWrite(a_rost, LOW);
  84.  
  85.   /* Se tutte le seguenti condizioni sono rispettate, allora -->*/
  86.   if( t_corsie > 23 && t_corsie < 26) digitalWrite(a_t_corsie, LOW);
  87.   else digitalWrite(a_t_corsie, HIGH);
  88.  
  89.   if( h_corsie > 40) digitalWrite(a_h_corsie, LOW);
  90.   else digitalWrite(a_h_corsie, HIGH);
  91.  
  92.   if(l_corsie < 300) digitalWrite(neon, HIGH);
  93.   else digitalWrite(neon, LOW);
  94.  
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement