Blue, THANKS! That's really good info. I appreciate the time you spent on helping me out! I was thinking there was a way to simplify what I'm trying to sketch and this looks much better than what I've got so far. I'm going to have to go look at some array tutorials because your code looks much more efficient than mine.
I would still like to understand why I'm not getting the correct readout on the display. I made some changes to the code I'm working but when I upload it, I only get one zero (0) in each space I have set for output on the display. I'm making progress but I'm still not there. Code is below.
#include <LiquidCrystal.h>
//First attempt at making a 4 zone auto watering system
//potPins values are just for setup purposes, must be calibrated once placed in soil
//potPins are to adjust the high and low moisture ranges for each zone
//must be used with Arduino Mega
LiquidCrystal lcd(7,8,9,10,11,12); //initialize library with the interface pins (these might need to be adjusted in the future)
const int zone1 = A0; //soil sensor for zone 1
const int zone2 = A1; //soil sensor for zone 2
const int zone3 = A2; //soil sensor for zone 3
const int zone4 = A3; //soil sensor for zone 4
const int potPinLow = A4; //low moisture pot
const int potPinHigh = A5; //high moisture pot
int potLow;
int potHigh;
const int valve1 = 2; //water valve 1
const int valve2 = 3; //water valve 2
const int valve3 = 4; //water valve 3
const int valve4 = 5; //water valve 4
int percent1; //mapped value of zone1
int percent2; //mapped value of zone2
int percent3; //mapped value of zone3
int percent4; //mapped value of zone4
int display1;
int display2;
int display3;
int display4;
void setup()
{
lcd.begin(16,2);
pinMode(valve1,OUTPUT);
pinMode(valve2,OUTPUT);
pinMode(valve3,OUTPUT);
pinMode(valve4,OUTPUT);
pinMode(potLow,INPUT);
pinMode(potHigh,INPUT);
int potLow = analogRead(potPinLow);
int potHigh = analogRead(potPinHigh);
int percent1 = analogRead(zone1);
}
void loop()
{
if(analogRead(zone1) <= potLow){ //read the value from the soil moisture sensor
digitalWrite(valve1,HIGH);} //open the valve
//delay(180000); //delay 3 minutes
if(analogRead(zone1) >= potHigh){ //when value from soil moisture sensor reaches the upper limit
digitalWrite(valve1,LOW); //close the valve
}
{
display1 = map(percent1,0,1023,0,99); //map zone1 range to 0-99
display2 = map(percent2,0,1023,0,99); //map zone2 range to 0-99
display3 = map(percent3,0,1023,0,99); //map zone3 range to 0-99
display4 = map(percent4,0,1023,0,99); //map zone4 range to 0-99
}
lcd.setCursor(0,0); //set the cursor to the first row and the first column
lcd.print(display1); //print mapped value of zone1
lcd.setCursor(9,0); //set the cursor to the first row and the ninth column
lcd.print(display2); //print mapped value of zone2
lcd.setCursor(0,1); //set the cursor to the second row and the first column
lcd.print(display3); //print mapped value of zone3
lcd.setCursor(9,1); //set the cursor to the second row and the ninth column
lcd.print(display4); //print mapped value of zone4
}