#include "FastLED.h" // define LED as an output for water level #define NUM_LEDS 1 #define DATA_PIN 9 // determine input sensors int sensorPinLDR = PC0; // select the input pin for LDR int sensorValueLDR = 0; // variable to store the value coming from the LDR sensor int sensorPinWater = PC1; // select the input pin for water level sensor int sensorValueWater = 0; // variable to store the value coming from the water level sensor int sensorPinHumidity = PC2; // select the input pin for humidity sensor int sensorValueHumidity = 0; // variable to store the value coming from the humidity sensor // Define the array of leds CRGB leds[NUM_LEDS]; void setup() { Serial.begin(9600); //sets serial port for communication FastLED.addLeds(leds, NUM_LEDS); // MOSFET PINS pinMode(PD5, OUTPUT);// PUMP pinMode(PD6, OUTPUT);// LIGHTS } void loop() { sensorValueLDR = analogRead(sensorPinLDR); // read the value from the sensor sensorValueWater = analogRead(sensorPinWater); sensorValueHumidity = analogRead(sensorPinHumidity); // Water level if (sensorValueWater < 10) { //Serial.println("NO WATER IN HERE!"); Serial.print(0); leds[0] = CRGB::Red; FastLED.show(); } else if (sensorValueWater < 400) { //Serial.println("NO WATER IN HERE!"); Serial.print(1); leds[0] = CRGB::Yellow; FastLED.show(); } else{ //Serial.println("ENOUGHT WATER IN HERE!"); Serial.print(1); leds[0] = CRGB::Green; FastLED.show(); } // Humidity if (sensorValueHumidity < 110) { //Serial.println("Dry Soil!"); digitalWrite(PD5, HIGH); //turn the pump on } else{ //Serial.println("Moist soil"); digitalWrite(PD5, LOW);// turn the pump off } // LIGHT if (sensorValueLDR < 400) { //Serial.println("Not enought Light"); digitalWrite(PD6, HIGH);// turn the Lights on } else{ //Serial.println("Enought Light"); digitalWrite(PD6, LOW); //turn the Lights off } delay(1000); }