I have a problem working with the LCD and Arduino.
When i use the example code for LiquidCrystal.h that displays HelloWorld the LCD works perfect. But when I add the same as part of another code, the LCD doesnt display well. it just flickers a few letters and then gradually fades away.
Basically I want to display the data that I get from a computer's browser that is connected to the same network that the Ethernet Shield is connected to. But I am just trying display the basic one so that I can edit accordingly.
#include <SPI.h>
#include <Ethernet.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
boolean incoming = 0;
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDA, 0x02 };
IPAddress ip(192,168,0,117);
EthernetServer server(80);
void setup()
{
lcd.begin(16, 2);
lcd.print("hello, world!");
Serial.begin(9600);
Ethernet.begin(mac, ip);
server.begin();
Serial.println("My IP Address is: ");
Serial.println(Ethernet.localIP());
}
void loop()
{
lcd.setCursor(0,1);
lcd.print(millis() / 1000);
EthernetClient client = server.available();
if (client) {
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
if(incoming && c == ' '){
incoming = 0;
}
if(incoming == 1){
Serial.println(c);
}
if(c == '$'){
incoming = 1;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
}
else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
delay(1);
client.stop();
}
}
The example code that works is:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
lcd.begin(16, 2);
lcd.print("hello, world!");
}
void loop() {
lcd.setCursor(0, 1);
lcd.print(millis() / 1000);
}