Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Inclusion bibliothèques
- #include <LiquidCrystal.h>
- //Creation Objet lcd pour le LCD
- LiquidCrystal lcd(12,11,5,4,3,2);
- //definition des pins utilisées
- const int fan1 = 6;
- //Variables globales
- unsigned long temps_Anterieur = 0;
- unsigned long temps_Actuel;
- const unsigned long long periode = 4000; // duree en milliseconde
- float val=24; // valeur de la temperature lue
- void setup ()
- {
- lcd.begin (16,2); //initialisation LCD
- pinMode(8,INPUT);
- pinMode(fan1,OUTPUT);
- }
- void loop ()
- {
- if (digitalRead (8 ))
- val= val+0.8;
- if (val > 29) { val= 24 ;
- }
- //affichage sur LCD
- lcd.setCursor(0,0);
- lcd.print ("T :");
- lcd.print (val);
- if (val > 26) //Si temperature >26°C,
- { temps_Actuel = millis();
- if(temps_Actuel - temps_Anterieur >= periode ) //Si 4 seconde se sont écoulées,
- {
- digitalWrite(fan1,LOW ); //demarrage ventilateur 1.
- }
- }
- else if (val < 25) //Si temperature < 25°C,
- {
- digitalWrite(fan1,HIGH); // eteindre ventilateur 1.
- }
- delay (1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement