I changed the LCD pins to
LiquidCrystal lcd(9, 8, 5, 4, 3, 2);
The same thing happens, I get Prueba, Prueba1, Prueba2 and Prueba3 correctly in the LCD, but Prueba4 prints like garbage, just random symbols. The following setup code gives me this result.
void setup() {
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
lcd.begin(16, 2);
lcd.print("Prueba");
delay(500);
lcd.clear();
zero=0x00;
// Open serial communications and wait for port to open:
// set up the LCD's number of columns and rows:
lcd.print("Prueba1");
delay(500);
lcd.clear();
// Initialize SdFat or print a detailed error message and halt
// Use half speed like the native library.
// change to SPI_FULL_SPEED for more performance.
lcd.print("Prueba2");
delay(500);
lcd.clear();
if (!sd.begin(chipSelect, SPI_HALF_SPEED)) sd.initErrorHalt();
lcd.print("Prueba3");
delay(500);
lcd.clear();
Wire.begin();
lcd.print("Prueba4");
delay(500);
}