81Views2Replies

Author Options:

help with my sketch anyone please.... Answered


const int TxPin = 6;       //lcd pin
const int buttonPin1 = 2;  //pins that are for
const int buttonPin2 = 3;  //buttons to open valves
const int buttonPin3  =  4;                       // and pumps
const int buttonPin4 = 5;   
const int pumpPin = 9;        //pin that turns on the pump   
const int valvePin1 = 13;        //pins that run valves
const int valvePin2 = 12;      
const int valvePin3 = 11;
const int valvePin4 = 10;
int buttonState1 = LOW;           //setting the button state to low
int buttonState2 = LOW;
int buttonState3 = LOW;
int buttonState4 = LOW;
const int PROBE1=A0, PROBE2=A1, PROBE3=A2, PROBE4=A3;
int MOISTURE_LEVEL = 250;                              //the value after the valves and pump goes ON

#include <SoftwareSerial.h>
SoftwareSerial mySerial = SoftwareSerial(255, TxPin);

void setup() {

   
   pinMode(pumpPin,OUTPUT);    // sets pumpPin to output
   pinMode(valvePin1,OUTPUT);    // sets valvePins to output
   pinMode(valvePin2,OUTPUT);
   pinMode(valvePin3,OUTPUT);
   pinMode(valvePin4,OUTPUT);
   pinMode(TxPin, OUTPUT);          //lcd pin to output
   digitalWrite(TxPin, HIGH);        
   digitalWrite(pumpPin, LOW);     
   digitalWrite  (valvePin1,LOW);
   digitalWrite(valvePin2,LOW);
   digitalWrite(valvePin3,LOW);
   digitalWrite(valvePin4,LOW);
   mySerial.begin(9600);
   mySerial.write(22);                // turns display on
   mySerial.write(17);                // turn on lcd back light  
   mySerial.write(12);                 // Clear  LCD
   delay(5);                          //required delay after clear Lcd
 
   
                            
}
void loop(){


   mySerial.write(128);        // sets sets lcd cursor to line 0 space 0
  mySerial.print("S1-");
 
   mySerial.write(148);           // sets lcd cursor to line 1 space 0
  mySerial.print( "S2-"); 

 
  mySerial.write(168);              //sets lcd cursor to line 2 space 0
  mySerial.print("S3-");
 

   mySerial.write(188);              //sets lcd cursor to line3 space 0
  mySerial.print( "S4-"); 
 
  mySerial.write(132);               //sets lcd cursor to line 0 space 4
  mySerial.print (analogRead(A0));
   mySerial.write(152);               //sets lcd cursor to line 1 space 4
  mySerial.print (analogRead(A1));
   mySerial.write(172);                //sets lcd cursor to line 2 space 4
  mySerial.print (analogRead(A2));
    mySerial.write(192);               //sets lcd cursor to line 3 space 4
  mySerial.print (analogRead(A3));
   
   
  
 
  if (analogRead(A3) < MOISTURE_LEVEL)
{
    digitalWrite(pumpPin, HIGH);
    digitalWrite(valvePin1, HIGH);

  else
  {
    digitalWrite(pumpPin, LOW);
    digitalWrite(valvePin4, LOW);
}
  if (analogRead(A1) < MOISTURE_LEVEL)
  {
    digitalWrite(pumpPin, HIGH);
    digitalWrite(valvePin2, HIGH);
}
  else
  {
    digitalWrite(pumpPin, LOW);
    digitalWrite(valvePin2, LOW);
}    
  if (analogRead(A2) < MOISTURE_LEVEL)
  {
    digitalWrite(pumpPin, HIGH);
    digitalWrite(valvePin3, HIGH);
}
  else
  {
    digitalWrite(pumpPin, LOW);
    digitalWrite(valvePin3, LOW);

  if (analogRead(A0) < MOISTURE_LEVEL)
  {
    digitalWrite(pumpPin,HIGH );
    digitalWrite(valvePin1, HIGH);
}
  else
{
    digitalWrite(pumpPin, LOW);
    digitalWrite(valvePin1, LOW);
}

Discussions

0
None
Kiteman

6 years ago

What help do you need?

0
None
JayefuuKiteman

Reply 6 years ago

+1.

What have you tried? What bits work? What bits don't? What are you trying to do? Are you trying to follow instructions or doing something new? What hardware are you using? Have you broken the code apart and tested each bit individually?