Paso 4: El código
#include < OneWire.h >#include < Wire.h >
#include < DallasTemperature.h >
#include < LiquidCrystal_I2C.h >
IMÁGENES
int bluePin1 = 10; Digital Pin für Blaue LED1 en RGB-LED
int greenPin1 = 11; Digital Pin für Grüne LED1 en RGB-LED
int redPin1 = 12; Digital Pin für LED1 Rote en RGB-LED
int redIn1 = 0;
int greenIn1 = 1;
int blueIn1 = 2;
int redVal1;
int greenVal1;
int blueVal1;
int bluePin2 = 4; Digital Pin für Blaue LED2 en RGB-LED
int greenPin2 = 5; Digital Pin für Grüne LED2 en RGB-LED
int redPin2 = 6; Digital Pin für LED2 Rote en RGB-LED
int redIn2 = 3;
int greenIn2 = 4;
int blueIn2 = 5;
int redVal2;
int greenVal2;
int blueVal2;
Relés de
int relPin1 = 2; Für Pin digital relé 1
int relPin2 = 3; Für Pin digital relé 2
int relPin3 = 8; Digital Pin für Relay3
int relPin1In = 3;
int relPin2In = 4;
int relPin3In = 5;
int relPin1Val;
int relPin2Val;
int relPin3Val;
Estado de Heizungs
int heiz1Val;
int heiz2Val;
#define BACKLIGHT_PIN 13
#define ONE_WIRE_BUS 7
Lcd(0x20,20,4) de LiquidCrystal_I2C; configurar la dirección de LCD a 0 x 20 para 20 caractéres y pantalla de 4 líneas
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors (& oneWire);
void setup() {}
Serial.Begin(9600);
Sensors.Begin();
LCD.init(); inicializar el lcd
LCD.Backlight();
pinMode (relPin1, salida); Modo de salida de relé 1
pinMode (relPin2, salida); Modo de salida de relé 2
pinMode (relPin3, salida); Modo de salida para Relay3
}
void loop() {}
sensors.requestTemperatures();
flotador temperature1 = sensors.getTempCByIndex(0);
lcd.setCursor (0, 0);
LCD.Print ("acuario:");
LCD.Print(Sensors.getTempCByIndex(0));
LCD.Print("C");
flotador temperature2 = sensors.getTempCByIndex(1);
lcd.setCursor (0, 2);
LCD.Print ("Becken:");
LCD.Print(Sensors.getTempCByIndex(1));
LCD.Print("C");
Je nach Temperatur Farbe der RGB-LED anpassen und 1 Rel schalten
Si (temperature1 < = 27)
{
redVal1 = 0;
greenVal1 = 0;
blueVal1 = 150;
relPin1Val = bajo;
relPin3Val = bajo;
lcd.setCursor (0, 1);
LCD.Print ("Heizung ist: Ein");
}
else if (temperature1 > 27 & & temperature1 < 29)
{
redVal1 = 0;
greenVal1 = 150;
blueVal1 = 0;
relPin1Val = alto;
relPin3Val = bajo;
lcd.setCursor (0, 1);
LCD.Print ("Heizung ist: Aus");
}
else if (temperature1 > 29)
{
redVal1 = 150;
greenVal1 = 0;
blueVal1 = 0;
relPin1Val = alto;
relPin3Val = alto;
lcd.setCursor (0, 1);
LCD.Print ("Lueftung ist: Ein");
}
Je nach Temperatur Farbe der RGB-LED anpassen und 2 Rel schalten
Si (temperature2 < = 27)
{
redVal2 = 0;
greenVal2 = 0;
blueVal2 = 255;
relPin2Val = bajo;
lcd.setCursor (0, 3);
LCD.Print ("Heizung ist: Ein");
}
else if (temperature2 > 27 & & temperature2 < 29)
{
redVal2 = 0;
greenVal2 = 255;
blueVal2 = 0;
relPin2Val = alto;
lcd.setCursor (0, 3);
LCD.Print ("Heizung ist: Aus");
}
else if (temperature2 > 29)
{
redVal2 = 255;
greenVal2 = 0;
blueVal2 = 0;
relPin2Val = alto;
lcd.setCursor (0, 3);
LCD.Print ("Lueftung ist: Ein");
}
{
analogWrite (redPin1, redVal1);
analogWrite (greenPin1, greenVal1);
analogWrite (bluePin1, blueVal1);
analogWrite (redPin2, redVal2);
analogWrite (greenPin2, greenVal2);
analogWrite (bluePin2, blueVal2);
digitalWrite (relPin1, relPin1Val);
digitalWrite (relPin2, relPin2Val);
digitalWrite (relPin3, relPin3Val);
}
}