Advertisement
alberane

Untitled

May 27th, 2022
863
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // A sample of code of how to use the lib
  2.  
  3. // The Lib
  4. #include <LM35.h>
  5.  
  6. //Set the sensor
  7. // Configuration: LM35 variable(pin);
  8. LM35 temp(A0);
  9.  
  10. float temperatura = 0;
  11.  
  12.  
  13. void setup()
  14. {
  15.   //Set the pin mode
  16.   pinMode(A0, INPUT);
  17.  
  18.   pinMode(10, OUTPUT);
  19.   pinMode(11, OUTPUT);
  20.   pinMode(12, OUTPUT);
  21. }
  22.  
  23. void loop()
  24. {
  25.  
  26.   if(temperatura < 10){
  27.     digitalWrite(10, HIGH);
  28.     digitalWrite(11, LOW);
  29.     digitalWrite(12, LOW);
  30.   }
  31.  
  32.   if((temperatura >= 10) && (temperatura < 35)){
  33.     digitalWrite(10, LOW);
  34.     digitalWrite(11, HIGH);
  35.     digitalWrite(12, LOW);
  36.   }
  37.  
  38.  
  39.   if((temperatura >= 35)){
  40.     digitalWrite(10, LOW);
  41.     digitalWrite(11, LOW);
  42.     digitalWrite(12, HIGH);
  43.   }
  44.  
  45.    
  46.   temperatura = temp.cel(); // Converts the data to Celsius and sends to serial
  47.   delay(250); // Delay to watch better the results
  48. }
  49.  
  50.  
Advertisement
RAW Paste Data Copied
Advertisement