//Program created by Daniela F //Library #include #define TX 1 SendOnlySoftwareSerial CustomSerial(TX); //--FC32 pin declaration - soil moisture int msensor = A7; //-- LED pins declaration int redpin = 11; //select the pin for the red LED int bluepin = 10; // select the pin for the blue LED int greenpin = 9; // select the pin for the green LED const int A = 0; //value dry const int B = 20; //value wet //--auxiliar Variables int humedad = 0; //FC32 int humedadmap = 0; int minhumedad = 20; void setup() { //declare pins pinMode(A7, INPUT); pinMode(redpin, OUTPUT); pinMode(bluepin, OUTPUT); pinMode(greenpin, OUTPUT); //Initalize serial comunication CustomSerial.begin(9600); } void loop() { //LEER VALORES //FC32 humedad = analogRead(msensor); humedadmap = map(humedad, 550, 10, 0 , 100); //hace regla de 3 //FC32 compare if (humedadmap <= minhumedad) { CustomSerial.println('a'); //Send the code for water needed digitalWrite(redpin, HIGH); digitalWrite(greenpin, LOW); digitalWrite(bluepin, LOW); delay(500); } else { // if ((humedadmap >= 0) && (humedadmap < minhumedad)) CustomSerial.println('b'); //Send the code for water not needed digitalWrite(redpin, LOW); digitalWrite(greenpin, HIGH); digitalWrite(bluepin, LOW); delay(500); } }