Display not responding to command (twitter integration) [SOLVED]

Hi I am trying to use my LCD display to make a scrolling text from twitter on Arduino UNO with Ethernet Shield
I used the code from this website and combine with the scrolling text’s example

The red text is where I force the feed to be displayed using autoscroll.

I tried this somewhere else and it works with the LCD screen(without the twitter protocol). With the twitter protocol, I can do Serial.print(text[thischar]); and it works perfectly.
The only problem is the LCD screen that is not working properly. The LCD suppose to display a message that it reads from the twitter feed then tell the LCD to display one character at a time. In this case, the message is “test tweet. Testing tweet for arudino tweeting machine. This is so glitchy lol”

However, my LCD didn’t show any text after I have assigned the IP address to the ethernet shield

Help me please.

here it is the part that it feeds in the twitter text to the String twitter

if (readingTweet) {
        if (inChar != '<') {
          tweet += inChar;
        } 
        else {
          // if you got a "<" character,
          // you've reached the end of the tweet:
          readingTweet = false;
          Serial.println(tweet);

          // Creating Char text to hold the message
          char text[tweet.length()];
          tweet.toCharArray(text, tweet.length()+1); // Insert String to Char 
          text_len = (sizeof(text)/sizeof(char))-1; // Finding how many char there are in the message
          lcd_limit = text_len - 16; 
          if(lcd_limit <= 0){
              Serial.println("The text is less than 16 char");
          }
          else{
                Serial.print("the text lenght is ");
                Serial.println(text_len);
          }

          //begin writing to LCD
          lcd.clear();
          lcd.setCursor(16,1);
          lcd.autoscroll();
          Serial.print("Here is the text ");
          Serial.println(text);
          //Writing to LCD
          for(int thisChar = 0; thisChar < text_len; thisChar++)
          {
              lcd.print(text[thisChar]);
              delay(200);
            }
          lcd.noAutoscroll();

I can also read in the variable ‘text’ using serial.print(text[thisChar]) and this works perfectly. So There is no problem displaying in on my computer screen

However, the LCD doesn’t seem to display any text

The funny thing is that if I run this code without connecting to the internet or Twitter (i.e. String twitter = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxx”) then the LCD displayed everything properly

I am not sure whether its a memory problem. This sketch is 18,380 bytes (of a 32,256 byte maximum)

Here is the full code

#include <LiquidCrystal.h>
#include <SPI.h>
#include <Ethernet.h>


// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 
  0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x01 };
IPAddress ip(192,168,1,20);
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// initialize the library instance:
EthernetClient client;
const unsigned long requestInterval = 30000;  // delay between requests

char serverName[] = "api.twitter.com";  // twitter URL

boolean requested;                   // whether you've made a request since connecting
unsigned long lastAttemptTime = 0;            // last time you connected to the server, in milliseconds

String currentLine = "";            // string to hold the text from server
String tweet = "";                  // string to hold the tweet
boolean readingTweet = false;       // if you're currently reading the tweet
int lcd_start = 0; // Position of the text
int text_len = 0; // limit on LCD
int lcd_limit = 0; // the limit of lcd


void setup() {
  // reserve space for the strings:
  currentLine.reserve(256);
  tweet.reserve(150);
  lcd.begin(16, 2);
  lcd.print("Twitter Starting");
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  // attempt a DHCP connection:
  Serial.println("Attempting to get an IP address using DHCP:");
  if (!Ethernet.begin(mac)) {
    // if DHCP fails, start with a hard-coded address:
    Serial.println("failed to get an IP address using DHCP, trying manually");
    Ethernet.begin(mac, ip);
  }
  Serial.print("My address:");
  Serial.println(Ethernet.localIP());
  // connect to Twitter:
  connectToServer();


}



void loop()
{
  if (client.connected()) {
    if (client.available()) {
      // read incoming bytes:
      char inChar = client.read();
      // add incoming byte to end of line:
      currentLine += inChar; 

      // if you get a newline, clear the line:
      if (inChar == '\n') {
        currentLine = "";
      } 
      // if the current line ends with <text>, it will
      // be followed by the tweet:
      if ( currentLine.endsWith("<text>")) {
        // tweet is beginning. Clear the tweet string:
        readingTweet = true; 
        tweet = "";
      }
      // if you're currently reading the bytes of a tweet,
      // add them to the tweet String:
      if (readingTweet) {
        if (inChar != '<') {
          tweet += inChar;
        } 
        else {
          // if you got a "<" character,
          // you've reached the end of the tweet:
          readingTweet = false;
          Serial.println(tweet);
          char text[tweet.length()];
          tweet.toCharArray(text, tweet.length()+1);
          text_len = (sizeof(text)/sizeof(char))-1;
          lcd_limit = text_len - 16;
          if(lcd_limit <= 0){
              Serial.println("The text is less than 16 char");
          }
          else{
                Serial.print("the text lenght is ");
                Serial.println(text_len);
          }

          //begin writing to LCD
          lcd.clear();
          lcd.setCursor(16,1);
          lcd.autoscroll();
          Serial.print("Here is the text ");
          Serial.println(text);
          //Writing to LCD
          for(int thisChar = 0; thisChar < text_len; thisChar++)
          {
              lcd.print(text[thisChar]);
              delay(200);
            }
          lcd.noAutoscroll();
          // close the connection to the server:
          Serial.println("Stopping Client");
          client.stop(); [/font][/color]
          
          
          
        }
      }
    }   
  }
  else if (millis() - lastAttemptTime > requestInterval) {
    // if you're not connected, and two minutes have passed since
    // your last connection, then attempt to connect again:
    connectToServer();
  }

}
void connectToServer() {
  // attempt to connect, and wait a millisecond:
  Serial.println("connecting to server...");
  if (client.connect(serverName, 80)) {
    Serial.println("making HTTP request...");
    // make HTTP GET request to twitter:
    client.println("GET /1/statuses/user_timeline.xml?screen_name=thaserty&count=1 HTTP/1.1");
    client.println("HOST: api.twitter.com");
    client.println();
  }
  // note the time of this connect attempt:
  lastAttemptTime = millis();
}

The only problem is the LCD screen that is not working properly.

The statement “not working properly” doesn’t give us much to work with.

What do you expect it to display?

What is it actually displaying?

Also - go back and highlight the code portion of your original post and then use the code button (it looks like a ‘#’ symbol) to properly format that code and make it legible as such…

Don

Edited. Thanks!

Just fixed this. I realized that the ethernet shield uses port 4 and several top ports. Now its working!

How did you fix this? I'm struggling with the same issue. How can you bypass the ethernet shield using pin4?