LCD displays garbled text after setCursor is called

Hi guys,

I'm currently working with the following:
Arduino UNO
Keyes USB Host Shield
1602A 16x2 LCD

I can display "Hello, World!" to my LCD, but any subsequent calls of setCursor() or print() result in a bunch of garbled text being displayed, and the first line being overwritten.(see attached image). When I remove setCursor or any additional prints, it displays one line of text properly.

I've checked and re-checked the pins. The USB Host shield manual says it doesn't use any pins from 0-7, and that they are just through pins.

I've poked around in the forums a bit but haven't found anything that directly addresses the issue.

Here's the code:

[color=red]#include <LiquidCrystal.h>[/color]

/*
Example sketch for the Xbox Wireless Reciver library - developed by Kristian Lauszus
It supports up to four controllers wirelessly
For more information see the blog post: http://blog.tkjelectronics.dk/2012/12/xbox-360-receiver-added-to-the-usb-host-library/ or
send me an e-mail:  kristianl@tkjelectronics.com
*/

#include <XBOXRECV.h>

// Satisfy the IDE, which needs to see the include statment in the ino too.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#include <SPI.h>
#endif

USB Usb;
XBOXRECV Xbox(&Usb);
unsigned int flip = 0;
[color=red]LiquidCrystal lcd(0, 1, 2, 3, 4, 5);[/color]

void setup() {

//Blink LED to detect hangs
//pinMode(13, OUTPUT);
// set up the LCD's number of columns and rows: 
[color=red]lcd.begin(16, 2); 
 lcd.home();
 lcd.print("hello, world!");[/color]
//Serial.begin(9600);
[color=red]lcd.setCursor(0, 1);
 lcd.print("Started");[/color]

Serial.begin(115200);
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start"));
while (1); //halt
}
Serial.print(F("\r\nXbox Wireless Receiver Library Started"));
}
void loop() {
Usb.Task();


if (Xbox.XboxReceiverConnected) {
for (uint8_t i = 0; i < 4; i++) {
 if (Xbox.Xbox360Connected[i]) {
   if (Xbox.getButtonPress(L2, i) || Xbox.getButtonPress(R2, i)) {
     Serial.print("L2: ");
     Serial.print(Xbox.getButtonPress(L2, i));
     Serial.print("\tR2: ");
     Serial.println(Xbox.getButtonPress(R2, i));
     Xbox.setRumbleOn(Xbox.getButtonPress(L2, i), Xbox.getButtonPress(R2, i), i);
   }

   if (Xbox.getAnalogHat(LeftHatX, i) > 7500 || Xbox.getAnalogHat(LeftHatX, i) < -7500 || Xbox.getAnalogHat(LeftHatY, i) > 7500 || Xbox.getAnalogHat(LeftHatY, i) < -7500 || Xbox.getAnalogHat(RightHatX, i) > 7500 || Xbox.getAnalogHat(RightHatX, i) < -7500 || Xbox.getAnalogHat(RightHatY, i) > 7500 || Xbox.getAnalogHat(RightHatY, i) < -7500) {
     if (Xbox.getAnalogHat(LeftHatX, i) > 7500 || Xbox.getAnalogHat(LeftHatX, i) < -7500) {
       Serial.print(F("LeftHatX: "));
       Serial.print(Xbox.getAnalogHat(LeftHatX, i));
       Serial.print("\t");
     }
     if (Xbox.getAnalogHat(LeftHatY, i) > 7500 || Xbox.getAnalogHat(LeftHatY, i) < -7500) {
       Serial.print(F("LeftHatY: "));
       Serial.print(Xbox.getAnalogHat(LeftHatY, i));
       Serial.print("\t");
     }
     if (Xbox.getAnalogHat(RightHatX, i) > 7500 || Xbox.getAnalogHat(RightHatX, i) < -7500) {
       Serial.print(F("RightHatX: "));
       Serial.print(Xbox.getAnalogHat(RightHatX, i));
       Serial.print("\t");
     }
     if (Xbox.getAnalogHat(RightHatY, i) > 7500 || Xbox.getAnalogHat(RightHatY, i) < -7500) {
       Serial.print(F("RightHatY: "));
       Serial.print(Xbox.getAnalogHat(RightHatY, i));
     }
     Serial.println();
   }

   if (Xbox.getButtonClick(UP, i)) {
     Xbox.setLedOn(LED1, i);
     Serial.println(F("Up"));
   }
   if (Xbox.getButtonClick(DOWN, i)) {
     Xbox.setLedOn(LED4, i);
     Serial.println(F("Down"));
   }
   if (Xbox.getButtonClick(LEFT, i)) {
     Xbox.setLedOn(LED3, i);
     Serial.println(F("Left"));
   }
   if (Xbox.getButtonClick(RIGHT, i)) {
     Xbox.setLedOn(LED2, i);
     Serial.println(F("Right"));
   }

   if (Xbox.getButtonClick(START, i)) {
     Xbox.setLedMode(ALTERNATING, i);
     Serial.println(F("Start"));
   }
   if (Xbox.getButtonClick(BACK, i)) {
     Xbox.setLedBlink(ALL, i);
     Serial.println(F("Back"));
   }
   if (Xbox.getButtonClick(L3, i))
     Serial.println(F("L3"));
   if (Xbox.getButtonClick(R3, i))
     Serial.println(F("R3"));

   if (Xbox.getButtonClick(L1, i))
     Serial.println(F("L1"));
   if (Xbox.getButtonClick(R1, i))
     Serial.println(F("R1"));
   if (Xbox.getButtonClick(XBOX, i)) {
     Xbox.setLedMode(ROTATING, i);
     Serial.print(F("Xbox (Battery: "));
     Serial.print(Xbox.getBatteryLevel(i)); // The battery level in the range 0-3
     Serial.println(F(")"));
   }
   if (Xbox.getButtonClick(SYNC, i)) {
     Serial.println(F("Sync"));
     Xbox.disconnect(i);
   }

   if (Xbox.getButtonClick(A, i))
     Serial.println(F("A"));
   if (Xbox.getButtonClick(B, i))
     Serial.println(F("B"));
   if (Xbox.getButtonClick(X, i))
     Serial.println(F("X"));
   if (Xbox.getButtonClick(Y, i))
     Serial.println(F("Y"));
 }
}
}


}


However, if I run just the LCD code, it works fine...

#include <LiquidCrystal.h>

LiquidCrystal lcd(0, 1, 2, 3, 4, 5);
#define   CONTRAST_PIN   
#define   BACKLIGHT_PIN  7
#define   CONTRAST       125

void setup()
{
// Switch on the backlight and LCD contrast levels
//  pinMode(CONTRAST_PIN, OUTPUT);
//  pinMode(BACKLIGHT_PIN, OUTPUT);

//  digitalWrite(BACKLIGHT_PIN, HIGH);
// analogWrite (CONTRAST_PIN, CONTRAST);
  
lcd.begin(16,2);               // initialize the lcd 

lcd.home ();                   // go home
lcd.print("Hello, ARDUINO ");  
lcd.setCursor ( 0, 1 );        // go to the next line
lcd.print (" WORLD!");      
}

Any help is greatly appreciated!

Your code cannot be properly analyzed since the forum software has modified it (you most likely didn't use italics when you wrote the code). Please edit your initial post and use the 'code' button to properly display your program code.

Also edit the topic heading and change LED to LCD.

Your code is not functioning properly because you are using pins 0 and 1 for the LCD and those pins are also being used by the Serial Monitor.

Don

Thanks Don. I figured out the Serial part was the conflict shortly after posting this.

Thanks for the quick reply. I'll use the proper formatting in the future.