hi
i have added a pic aswell as code im using on garden monitor it all works well apart from ive got to up the values that it puts pump on/ off but thats the easy part another question along the lines of nrf24lo1 if i had these talking together and to my pc could i update the sketch on the garden one from my laptop instead od carrying it outside and plugging into usb only a thought
regards colin
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
//#include <PCD8544.h>
//PCD8544 lcd;
int sensor_pin = A0 ;
int output_value = 0;//changed
int valve_pin = 8 ;//relay
void setup ( ) {
Serial.begin(9600);//changed
Serial.print ("Reading From the " );
Serial.print (" Moisture = ");
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print ("Reading From the " );
lcd.setCursor(0, 1);
pinMode (valve_pin, OUTPUT);
delay (2000);
}
void loop ( ) {
output_value = analogRead (sensor_pin);
output_value = map (output_value , 1023 ,0 , 0 , 170);
lcd.clear ( );
lcd.setCursor (0, 0);
lcd.print (" Moisture = ");
lcd.print (output_value);
lcd.setCursor (0, 1);
//if (output_value < 40)//changed
//if ((output_value < 40)&&(output_value > 70))//changed
if (output_value <= 50) //turn valve on
//if (output_value >= 70) //turn valve off
{
lcd.print (" Valve: ON ");
digitalWrite(6, HIGH); //green
digitalWrite(7, LOW); //red
digitalWrite (valve_pin , LOW); //Relay operates on opposite signal
delay (20000);
}
else
{
//if (output_value > 70)//changed
lcd.print (" Valve: OFF ");
if (output_value >= 80)
//turn valve off
digitalWrite(6, LOW); //green
digitalWrite(7, HIGH); //red
digitalWrite (valve_pin , HIGH); //Relay operates on opposite signal
delay (1000);
}
delay(1000);
}