Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: moisture sensors on: February 18, 2013, 08:49:38 am
the valvepin  are  leds to show which valves are open and the pump is on...the relaypins control one pump and four valves. i ve been reading about arrays but really dont understand them or how i would use them....
2  Using Arduino / Programming Questions / Re: moisture sensors on: February 12, 2013, 11:53:24 pm
again thank you....this is what i've come up with so for all of it works....
Code:

const int TxPin = 6;       //lcd pin
const int relayPin1 = 4;  //pins that are for
const int relayPin2 = 3;  //buttons to open valves
const int relayPin3 = 2;                       // and pumps
const int relayPin4 = 5;
const int relayPin5 = 7;
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;
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(relayPin5, OUTPUT); 
   pinMode(relayPin4, OUTPUT);   
   pinMode(relayPin1, OUTPUT);   
   pinMode(relayPin2, OUTPUT);   
   pinMode(relayPin3, OUTPUT);   
   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);
   digitalWrite(relayPin1,LOW);
   digitalWrite(relayPin2,LOW);
   digitalWrite(relayPin3,LOW);
   digitalWrite(relayPin4,LOW);
   digitalWrite(relayPin5,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()
{
   int val0 = analogRead(A0);
   int val1 = analogRead(A1);
   int val2 = analogRead(A2);
   int val3 = analogRead(A3); 
   
   mySerial.write(128);
  mySerial.print("S1-");
   mySerial.write(148); 
  mySerial.print( "S2-"); 
  mySerial.write(168);
  mySerial.print("S3-");
   mySerial.write(188); 
  mySerial.print( "S4-"); 
   mySerial.write(132); 
  mySerial.print (analogRead(A0));
   mySerial.write(152); 
  mySerial.print (analogRead(A1));
   mySerial.write(172);
  mySerial.print (analogRead(A2));
    mySerial.write(192);
  mySerial.print (analogRead(A3));
   
   
   if(val0 < MOISTURE_LEVEL)
 {
      digitalWrite(valvePin1, HIGH);
      digitalWrite(relayPin1, HIGH);
 }     
 else
 {
       digitalWrite(valvePin1, LOW);
       digitalWrite(relayPin1, LOW);
 }   
   if(val1 < MOISTURE_LEVEL)
  {
      digitalWrite(valvePin2, HIGH);
      digitalWrite(relayPin2, HIGH);
  }
   else
   {
       digitalWrite(valvePin2, LOW);
       digitalWrite(relayPin2, LOW);
   }       
   if(val2 < MOISTURE_LEVEL)
   {
      digitalWrite(valvePin3, HIGH);
      digitalWrite(relayPin3, HIGH);
   }
   else
   {
       digitalWrite(valvePin3, LOW);
       digitalWrite(relayPin3, LOW);
   }           
   if(val3 < MOISTURE_LEVEL)
   {
      digitalWrite(valvePin4, HIGH);
      digitalWrite(relayPin4, HIGH);
   }
   else
   {
       digitalWrite(valvePin4, LOW);
        digitalWrite(relayPin4, LOW);
   }
   if(val0 < MOISTURE_LEVEL ||
       val1< MOISTURE_LEVEL ||
       val2< MOISTURE_LEVEL ||
       val3< MOISTURE_LEVEL)
   {
      digitalWrite(pumpPin, HIGH);
      digitalWrite(relayPin5, HIGH);
   }
   else
   {
      digitalWrite(pumpPin, LOW);
      digitalWrite(relayPin5, LOW);
   }
}
i would love to add buttons to control each valve..
3  Using Arduino / Programming Questions / Re: moisture sensors on: February 12, 2013, 09:07:25 pm
It works perfect thank u so much.....if i were to add buttons would i do them the same ?
4  Using Arduino / Programming Questions / Re: moisture sensors on: February 12, 2013, 03:03:54 pm
thanku ill give this a try....
5  Using Arduino / Programming Questions / Re: moisture sensors on: February 12, 2013, 01:54:07 am
example please
6  Using Arduino / Programming Questions / Re: moisture sensors on: February 12, 2013, 12:51:21 am
ok how do i change it? and why does it only do it for one valve and non of the others?
7  Using Arduino / Programming Questions / Re: moisture sensors on: February 11, 2013, 11:33:34 pm
its still flickering.....yes i run one pump and four valves , the pump and valve are suppose to turn on when the the sensor is dry..i didnt put equal in cause i thought i wouldnt matter
Code:
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);

}
}
8  Using Arduino / Programming Questions / Re: moisture sensors on: February 11, 2013, 02:02:23 pm

Hope this is better, any more suggestions? Sorry i for the forgotten semi colons when i was typing it out.  at the moment i have leds to represent the pump and valve relays.

Code:
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);
}
9  Using Arduino / Programming Questions / Re: moisture sensors on: February 11, 2013, 12:00:05 pm



im trying to read 4 moisture sensors on a parallax lcd, and turn a pump and valve on when they hit a certain level i got all the led the represent the pumps and valves to light up and turn off when i want except the last one A0 it flashes instead of being solid i have everything hook up right i think i have no problem doing one sensor more then that










Code:
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                \\analog pin A0-A4 moisture sensors
const int PROBE2= A1                 \\called PROBE1- PROBE4
const int PROBE3= A2
const int PROBE4= A0
int MOISTURE_LEVEL = 250;                              // the value after the valves and pump goes ON

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

void setup() {

      pinMode(PROBE1,INPUT);                    \\ sets PROBE1-PROBE4 TO input
      pinMode(PROBE2,INPUT);                   
   pinMode(PROBE3,INPUT)                                     
   pinMode(PROBE4,INPUT);             
   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, LOW);
    digitalWrite(valvePin4, LOW);

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

  if (analogRead(A0) > MOISTURE_LEVEL)
  {
    digitalWrite(pumpPin, LOW);
    digitalWrite(valvePin1, LOW);
}
  if (analogRead(A0) < MOISTURE_LEVEL)
{
    digitalWrite(pumpPin, HIGH);
    digitalWrite(valvePin1, HIGH);
}
}
10  Using Arduino / Programming Questions / Re: moisture sensors on: February 11, 2013, 01:29:52 am
please more help.....im new
11  Using Arduino / Programming Questions / moisture sensors on: February 10, 2013, 10:15:40 pm
im having problems with my sketch i just started a month ago so im a newbie....if anyone can help me fix this PLEASE

Code:
const int TxPin = 6;
const int buttonPin1 = 2;  
const int buttonPin2 = 3;  
const int buttonPin3 = 4;  
const int buttonPin4 = 5;  
const int pumpPin = 9;                
const int valvePin1=13;        
const int valvePin2 = 12;
const int valvePin3 = 11;
const int valvePin4 = 10;
int buttonState1 = LOW;
int buttonState2 = LOW;
int buttonState3 = LOW;
int buttonState4 = LOW;
const int PROBE = A0-A4; // Analog pin 0-3
int MOISTURE_LEVEL = 250; // the value after the LED goes ON

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

void setup() {
  
   pinMode(PROBE,INPUT);
   pinMode(pumpPin,OUTPUT);
   pinMode(valvePin1,OUTPUT);
   pinMode(valvePin2,OUTPUT);
   pinMode(valvePin3,OUTPUT);
   pinMode(valvePin4,OUTPUT);
   pinMode(TxPin, OUTPUT);
   digitalWrite(TxPin, HIGH);
   digitalWrite(pumpPin, HIGH);
   digitalWrite  (valvePin1,HIGH);
   digitalWrite(valvePin2,HIGH);
   digitalWrite(valvePin3,HIGH);
   digitalWrite(valvePin4,HIGH);
   mySerial.begin(9600);
   mySerial.write(12);                 // Clear  
   delay(5);  
   mySerial.write(17);
   mySerial.write(22);  //
                             // Required d
}
void loop(){


   mySerial.write(128);
  mySerial.print("S1-");
  
   mySerial.write(148);  
  mySerial.print( "S2-");  

 
  mySerial.write(168);
  mySerial.print("S3-");
 

   mySerial.write(188);  
  mySerial.print( "S4-");  
  
  mySerial.write(132);  
  mySerial.print (analogRead(A0));
   mySerial.write(152);  
  mySerial.print (analogRead(A1));
   mySerial.write(172);
  mySerial.print (analogRead(A2));
    mySerial.write(192);
  mySerial.print (analogRead(A3));
    
    
  
  
  if (analogRead(A3) > MOISTURE_LEVEL)
{
    digitalWrite(pumpPin, LOW);
    digitalWrite(valvePin4, LOW);
}  
  if (analogRead(A3) < MOISTURE_LEVEL)
  {
    digitalWrite(pumpPin, HIGH);
    digitalWrite(valvePin4, HIGH);
}
  if (analogRead(A1) > MOISTURE_LEVEL)
  {
    digitalWrite(pumpPin, LOW);
    digitalWrite(valvePin2, LOW);
}
  if (analogRead(A1) < MOISTURE_LEVEL)
  {
    digitalWrite(pumpPin, HIGH);
    digitalWrite(valvePin2, HIGH);
}    
  if (analogRead(A2) > MOISTURE_LEVEL)
  {
    digitalWrite(pumpPin, LOW);
    digitalWrite(valvePin3, LOW);
}
  if (analogRead(A2) < MOISTURE_LEVEL)
  {
    digitalWrite(pumpPin, HIGH);
    digitalWrite(valvePin3, HIGH);
}  
  if (analogRead(A0) > MOISTURE_LEVEL)
  {
    digitalWrite(pumpPin, LOW);
    digitalWrite(valvePin1, LOW);
}
  if (analogRead(A0) < MOISTURE_LEVEL)
{
    digitalWrite(pumpPin, HIGH);
    digitalWrite(valvePin1, HIGH);
}
}


it works sort of...i wanna add buttons for each valve but one step at a time i guess smiley-confuse


Moderator edit: [code] [/code] tags added.
Pages: [1]