Advertisement
Guest User

Untitled

a guest
Jun 13th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Inclusion bibliothèques
  2. #include <LiquidCrystal.h>
  3.  
  4. //Creation Objet lcd pour le LCD
  5. LiquidCrystal lcd(12,11,5,4,3,2);
  6.  
  7. //definition des pins utilisées
  8. const int fan1 = 6;
  9.  
  10. //Variables globales
  11. unsigned long temps_Anterieur = 0;
  12. unsigned long temps_Actuel;
  13. const unsigned long long periode = 4000; // duree en milliseconde
  14. float val=24; // valeur de la temperature lue
  15.  
  16. void setup ()
  17. {
  18. lcd.begin (16,2); //initialisation LCD
  19. pinMode(8,INPUT);
  20. pinMode(fan1,OUTPUT);
  21. }
  22. void loop ()
  23. {
  24. if (digitalRead (8 ))
  25. val= val+0.8;
  26. if (val > 29) { val= 24 ;
  27. }
  28. //affichage sur LCD
  29. lcd.setCursor(0,0);
  30. lcd.print ("T :");
  31. lcd.print (val);
  32.  
  33. if (val > 26) //Si temperature >26°C,
  34. { temps_Actuel = millis();
  35.  
  36. if(temps_Actuel - temps_Anterieur >= periode ) //Si 4 seconde se sont écoulées,
  37. {
  38. digitalWrite(fan1,LOW ); //demarrage ventilateur 1.
  39. }
  40. }
  41. else if (val < 25) //Si temperature < 25°C,
  42. {
  43. digitalWrite(fan1,HIGH); // eteindre ventilateur 1.
  44.  
  45. }
  46. delay (1000);
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement