How to use a standard 16X2 LCD with the Arduino
Comment out anything that doesnt have to do with the LCD then get the LCD working. That way you know you don't have more than one dragon to slay.
Your code looks fine to me, can't really help any more without a picture.
<p>Hi,</p><p>I am making a soil hygrometer, but i wanna print it to LCD, i am new to arduino actualy this is my second thing im doing. The LCD Lights up in blue and i can see white pixels in blocks... the hygrometer works and its in a glass measuring doing its job like it should as i can see in the serial monitor, but my lcd is not doing getting any digits just blocks.. when i add a delay in void loop then i see some flickering on the lcd everytime the hygrometer measures and sends it to the serial monitor.. how can i build this correctly?</p><p>#include &lt;LiquidCrystal.h&gt;</p><p>int soil=0;</p><p>int SensorPin = A1;</p><p>int SensorValue;</p><p>int pinNumber = 2; </p><p>LiquidCrystal lcd(2, 3, 4, 5, 6, 7);</p><p>void setup() {</p><p> // read the input on analog pin 0:</p><p> int sensorValue = analogRead(A0);</p><p> sensorValue = constrain(sensorValue, 485, 1023);</p><p> // print out the value you read:</p><p> //Serial.println(sensorValue);</p><p> //map the value to a percentage</p><p> soil = map(sensorValue, 485, 1023, 112, 0);</p><p> // print out the soil water percentage you calculated:</p><p> Serial.print(soil);</p><p> Serial.println(sensorValue);</p><p> Serial.begin(9600);</p><p> delay(1000); </p><p> //////////////////////////////////////</p><p> pinMode(pinNumber, OUTPUT);</p><p> pinMode(SensorPin, INPUT);</p><p> lcd.begin(16, 2);</p><p> lcd.print(&quot; dendans soil &quot;);</p><p> lcd.setCursor(0,1);</p><p> lcd.print(&quot;moisture sensor &quot;);</p><p> delay(5000);</p><p> lcd.clear();</p><p> lcd.setCursor(0,0);</p><p> lcd.print(&quot;High value = dry&quot; );</p><p> lcd.setCursor(0,1);</p><p> lcd.print(&quot;Low value = wet&quot;);</p><p> delay(3000);</p><p> lcd.clear();</p><p> lcd.print(&quot; optimum value&quot;);</p><p> lcd.setCursor(0,1);</p><p> lcd.print(&quot; &gt; 35------65 &lt;&quot;);</p><p> delay(3000);</p><p> lcd.clear();</p><p> Serial.begin(9600);</p><p> Serial.print(&quot;soil moisture sensor&quot;);</p><p>}</p><p>void loop() {</p><p> int sensorValue = analogRead(A0); Serial.println(sensorValue);</p><p> SensorValue = analogRead(SensorPin);</p><p> lcd.setCursor(0,0);</p><p> lcd.print(&quot; moisture value &quot;);</p><p> lcd.setCursor(0,1);</p><p>lcd.print(&quot;testest&quot;);</p><p>lcd.print(SensorValue/10.3);</p><p> lcd.setCursor(0,1);</p><p> lcd.clear();</p><p> lcd.setCursor(0,1);</p><p> lcd.print(SensorValue/10.3);</p><p> if(analogRead(1)&gt;901 &amp;&amp; analogRead(1)&lt; 1023)</p><p> {lcd.print(&quot; Not in use&quot;);}</p><p> if(analogRead(1)&gt;701 &amp;&amp; analogRead(1)&lt; 900)</p><p> {lcd.print(&quot; : dead dry&quot;);} </p><p> if(analogRead(1)&gt;(601) &amp;&amp; analogRead(1)&lt; 700)</p><p> {lcd.print(&quot; : too dry&quot;);}</p><p> if(analogRead(1)&gt;350 &amp;&amp; analogRead(1)&lt; 600)</p><p> {lcd.print(&quot; : perfect&quot;);}</p><p> if(analogRead(1)&gt;201 &amp;&amp; analogRead(1)&lt; 349)</p><p> {lcd.print(&quot; : too wet&quot;);}</p><p> if(analogRead(1)&lt;200)</p><p> {lcd.print(&quot; : drowning&quot;);}</p><p>}</p>
<p>If you get back to me on the contrast and that doesn't work I will then check out your code. It really sounds like contrast though. Have you made a &quot;Hello World&quot; type run on that LCD yet?</p>
<p>Ok im gonna figure it out now, at least try. and the contrast works fine.</p><p>with potentiometer.</p>
First thing - have you tried adjusting the contrast? At one end of the contrast scale, you won't see anything, at the other end you will just see white blocks.
<p>Yes that works fine with the potentiometer, but its just not printing the data from the hygrometer to the lcd, i need this project pretty soon.</p>

About This Instructable




Bio: Electronics are a newly re-found hobby for me. I'm not an engineer - I'm an ordinary guy who likes to tinker with electronics in ... More »
More by meanpc:How to Negotiate at Garage Sales How to Plan Your Garage Sale Route Using Google Earth (for EBay Sellers) Potentiometers and AnalogRead - How to Arduino #4 
Add instructable to: