int Led1 = 2; // Pin del LED
int Led2 =0; // Pin del LED
int Led3 = 4; // Pin del LED
String temperaturaString = "35"; // Ejemplo de temperatura como string
int temperaturaInt;
// Ejemplo de humedad como string
String HumedadString = "24";
int HumedadInt;
// Ejemplo de distancia como string
String DistanciaString = "10";
int DistanciaInt;
void setup() {
pinMode(Led1, OUTPUT);
pinMode(Led2, OUTPUT);
pinMode(Led3, OUTPUT);
}
void loop() {
temperaturaInt = temperaturaString.toInt(); // Convertimos el string a int
HumedadInt = HumedadString.toInt(); // Convertimos el string a int
DistanciaInt = DistanciaString.toInt(); // Convertimos el string a int
if (temperaturaInt > 38) {
digitalWrite(Led1, HIGH); // Enciende el LED
} else {
digitalWrite(Led1, LOW); // Apaga el LED
}
if (HumedadInt > 85) {
digitalWrite(Led2, HIGH); // Enciende el LED
} else {
digitalWrite(Led2, LOW); // Apaga el LED
}
if (DistanciaInt > 60) {
digitalWrite(Led3, HIGH); // Enciende el LED
} else {
digitalWrite(Led3, LOW); // Apaga el LED
}
// Código adicional puede ir aquí
}