Paste
Copy
Cut
Options

¡Tu solución está lista!

Nuestra ayuda de expertos desglosó tu problema en una solución confiable y fácil de entender.

Mira la respuesta
  • Pregunta: Hi!! Thank you in advance for your time and your response :) My question is, for the following arduino code, do I need a relay? And if the answer is yes, what part of the code does the relay help with? const int sensorHumedadPin = A0;const int bombaAguaPin = 8;const float pendiente = 399.6;const float interseccion = 123;const int umbralBomba = 50;void

    Hi!! Thank you in advance for your time and your response :) My question is, for the following arduino code, do I need a relay? And if the answer is yes, what part of the code does the relay help with?

    const int sensorHumedadPin = A0;

    const int bombaAguaPin = 8;

    const float pendiente = 399.6;

    const float interseccion = 123;

    const int umbralBomba = 50;


    void setup() {
    pinMode(sensorHumedadPin, INPUT);
    pinMode(bombaAguaPin, OUTPUT);
    digitalWrite(bombaAguaPin, LOW);
    Serial.begin(9600);
    }


    void loop() {
    int lecturaHumedad = analogRead(sensorHumedadPin);
    int tiempoActivacion = constrain((lecturaHumedad * pendiente) + interseccion, 0, 2000);
    Serial.print("Humedad: ");
    Serial.print(lecturaHumedad);
    Serial.print(", Tiempo de Activación: ");
    Serial.print(tiempoActivacion);

    if(lecturaHumedad < umbralBomba) {
    activarBomba(tiempoActivacion);
    }
    delay(15000);
    }


    void activarBomba(int tiempoActivacion) {
    digitalWrite(bombaAguaPin, HIGH);
    delay(tiempoActivacion);
    digitalWrite(bombaAguaPin, LOW);
    }

  • Chegg Logo
    Queda solo un paso para resolver este problema.
    Solución
    100(1 calificación)
    Paso 1

    Answer:


    The need for a relay in your Arduino setup depends on the type of device you’re controlling w...

    Mira la respuesta completa
    answer image blur
    Respuesta
    Desbloquea