Hi.. my LCD display row of block in first row after i click serial monitor on arduino software. before this, the LCD is okay. my project is rain sensor with ethernet shield . already check there is no solder problem and wired up correctly. this is my coding. please help me
#define RELAY1 7
#include <Ethernet.h>
#include <SPI.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 177);
EthernetServer server(80);
#include <LiquidCrystal.h>
int nRainIn = A1;
int nRainDigitalIn = 6;
int nRainVal;
boolean bIsRaining = false;
String strRaining;
LiquidCrystal lcd(5, 4, 3, 2, 1, 0);
void setup() {
Ethernet.begin(mac, ip);
server.begin();
lcd.begin(16,2);
lcd.print("status:");
pinMode(6,INPUT);
pinMode(RELAY1, OUTPUT);
}
void loop() {
nRainVal = analogRead(nRainIn);
bIsRaining = !(digitalRead(nRainDigitalIn));
if(bIsRaining){
strRaining = "YES";
digitalWrite(RELAY1,0); // Turns ON Relays 1
// lcd.println("Light ON");
}
else{
strRaining = "NO";
digitalWrite(RELAY1,1); // Turns Relay Off
//lcd.println("Light OFF");
}
lcd.begin(16, 2);
lcd.print("Raining?: ");
lcd.print(strRaining);
lcd.setCursor(0, 1);
lcd.print("\t Moisture Level: ");
lcd.println(nRainVal);
delay(200);
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 5"); // refresh the page automatically every 5 sec
client.println();
client.println("");
client.println("");
client.println("");
client.println("");
client.println("PSM2");
client.println("");
client.println("
RAIN STATUS AT UTHM
");// output the value of each analog input pin
client.print("Raining?: ");
client.print(strRaining);
client.print("\t Moisture Level: ");
client.print(nRainVal);
client.println("
");
client.println("");
break;
}
}
}
}
// give the web browser time to receive the data
Ethernet.maintain();
}