Problem
I can't get my Arduino Uno's LiquidCrystal library to print to my LCD screen when using the Ethernet library (and shield, of course).
Code
#include <SPI.h>
#include <Ethernet.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
EthernetClient client;
String text = "Original Text";
void setup() {
// Set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Setup Text");
// We have serial, but no milk!
Serial.begin(9600);
}
void loop() {
text = "Altered Text";
if (Ethernet.begin(mac) != 0) {
Serial.println("Some Ethernet work...");
}
lcd.setCursor(0, 1);
lcd.print(text);
}
Expected Result
Let ▓
represent a blank character.
The screen should print:Setup▓Text▓▓▓▓▓▓
Altered▓Text▓▓▓▓
While Some Ethernet work...
prints to Serial.
Actual Result
The screen prints:Setup▓Text▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
While Some Ethernet work...
prints to Serial.
Notes
If I comment out the Ethernet code in the loop, I get the Expected Result.
My question is similar -- but not identical to -- this question:
Arduino code anomalies - LCD fails with multiple 'if' statements
I don't believe my problem is a shortage of memory. I am using the most up-to-date Ethernet library, which fixes a memory leak bug from a previous version.