1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
// Je charge les librairies
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
int relais = 51; //Ont assigne le relais a la broche 51
int temp_sensor = 49; //Ont assigne la sonde a la broche 53
float temperature = 0; //Ont creer les variable
int lowerLimit = 18;
OneWire oneWirePin(temp_sensor);
DallasTemperature sensors(&oneWirePin);
// select the pins used on the LCD panel
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup(void)
{
lcd.begin(16, 2);
lcd.setCursor(1, 0);
lcd.print ("HELLO");
pinMode(relais, OUTPUT);
sensors.begin();
}
void loop() {
sensors.requestTemperatures();
temperature = sensors.getTempCByIndex(0);
//AFFICHAGE TEMPERATURE LCD
lcd.setCursor(1, 0);
lcd.print ("Temp: ");
lcd.setCursor(7, 0);
lcd.print(temperature);
//AFFICHAGE LCD ETAT RELAIS
if (temperature < lowerLimit) {
lcd.setCursor(1, 1);
lcd.print("Relais OFF");
}
else if (temperature > lowerLimit ) {
lcd.setCursor(1, 1);
lcd.print("Relais ON ");
}
//GESTION DU RELAIS
if (temperature < lowerLimit) {
digitalWrite(relais, LOW);
}
else if (temperature > lowerLimit ) {
digitalWrite(relais, HIGH);
}
} |
Partager