//+++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++
#define LED 13 //LED EN PLACA ARDUINO & SHIELD
#define BUZZER 8 //ZUMBADOR EN EL PIN #8
int RED=A2; //LED ROJO
int YELLOW=A1; //LED AMARILLO
int GREEN=A0; //LED VERDE
int HUMEDAD=A3; //SENSOR DE HUMEDAD
int VALOR; //GUARDA EL VALOR DEL SENSOR
void APAGAR() { //APAGAR LOS TRES LEDS
analogWrite(RED,0);
analogWrite(YELLOW,0);
analogWrite(GREEN,0);
}
void setup() {
// put your setup code here, to run once:
pinMode(LED,OUTPUT); //LED PLACA ARDUINO
pinMode(BUZZER,OUTPUT); //PIN TO BUZZER
Serial.begin(9600); //VELOCIDAD DE PUERTO SERIE
digitalWrite(LED,HIGH); //LED SYSTEM "TURN ON"
}
void loop() {
// put your main code here, to run repeatedly:
APAGAR(); //APAGAR TODOS LOS LEDS
VALOR=analogRead(HUMEDAD);//LEER EL VALOR DE HUMEDAD
Serial.print(VALOR); //ESCRIBIR EN LA COMPUTADORA
if(VALOR>0 & VALOR<500){//INTENSAMENTE HUMED0
analogWrite(GREEN,255);
}
if(VALOR>500 & VALOR<800){//POCA HUMEDAD
analogWrite(YELLOW,255);
}
if(VALOR>800 & VALOR<1024){//AMBIENTE SECO
analogWrite(RED,255);
tone(BUZZER,1000,500);
}
delay(3000);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++
https://nbrobots.blogspot.com/2019/03/sensor-de-humedad-2.html
Les deseo mucho éxito
y sigamos programando!!!