New to arduino and this forum,
i would appreciate if i could get some help with having my analog sensor value displayed
to my "keypad lcd shield"
Values are from a soil moisture sensor, and i get the in serial com in computer,
but instead of running around with my plants back and forth to my computer i would like to read the value on my lcd shield
and power the arduino with a battery
so, after spending a couple of evenings of trying to copying others lcd codes and trying to mix them with the code i run
i have to give up before i go all nuts
here is the code i run, and if someone would create the rest of whatever it takes to have value displayed on my lcd i would be very happy
I fill in the first pins i use as i have the older lcd
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
# Example code for the moisture sensor
# Editor : Lauren
# Date : 13.01.2012
# Version : 1.0
# Connect the sensor to the A0(Analog 0) pin on the Arduino board
# the sensor value description
# 0 ~300 dry soil
# 300~700 humid soil
# 700~950 in water
*/
void setup(){
Serial.begin(9600);
Serial.print("soil moisture sensor");
delay(2000);
}
void loop(){
Serial.print("Moisture Sensor Value:");
Serial.println(analogRead(1
));
delay(1000);
}
I might have solved the issue, to get the analog readings to my lcd ,
However a new problem appeared,
I get 1 extra digit on the lcd, when i hold sensor in dry air , it displays correct 1023, but when immerse in wet soil
the number go nuts, instead of printing 312 as the serial com , it prints 3124on lcd
You was right about the problem, it was so obvious, that i would never had figured it out
But i did not get your code to work properly
However i figured that by dividing the 1023 by 10,3 to get the output full span reading between 0-99 (15-99 in reality) i avoided
to have a remaining digit on the screen
Anyone feel free to refine , its my first code i write , so i don't doubt it could get better.
If anyone know how to reverse the values ,so that higher (ohm) values would mean more moisture ,it would be great,
You're using delays.
Get rid of those in your 'loop', learn to do without delays as soon as possible.
You can find out how by playing around with the 'blink without delay' sketch, found in the examples that came with the IDE.
Do you see the display blinking if you take a real good look at it ?
It actually does so because that is what you make it do at the moment.
Instead of clearing the entire display, print spaces over the position where you like to print your values, then print the new value over that.
If you first check that value for changes, and do not (needlessly) erase and rewrite if the value didn't change, you can do perfectly well without any delay (either way) at all and have a very stable display.