Go Down

Topic: [SOLVED]LCD 16x2 showing garbage (Read 8 times) previous topic - next topic

mrescude

Ok I'll change that, I wasn't aware that they were the same pins...

mrescude

I changed the LCD pins to
Code: [Select]
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.

Code: [Select]

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);
 
}


liudr


Ok I'll change that, I wasn't aware that they were the same pins...

All SPI devices such as SD card, use the SPI bus pins, 11,12,13. 10 is simply used as chip select to tell the chip the communication is for that chip. Adafruit SD card shield uses 10 so make sure you find which pin sparkfun SD card uses for CS, chip select, could be pin 4, and avoid that pin. FYI the analog pins 0-5 can be used as digital pins 14-19 if you run out of pins.

mrescude

I'm using the Arduino Ethernet Shield, so CS is pin 10. I get the problem after calling Wire.begin(), and i have no idea how to avoid that, cause I need that to get or set the date from the RTC.

liudr

OK, just avoid pin 4 too:

Quote
const int chipSelect = 4;


I guess if you use the Ethernet, avoid pin 10 and 4. Since you have RTC on I2C bus, also avoid analog pins 4 and 5 :) You don't have many pins left, do you?

Program upload uses 0,1
Ethershield with SD card uses 4,10,11,12,13
RTC uses 18,19 (aka analog 4,5)

So you have left 2,3,5,6,7,8,9,14,15,16,17
You will use 6 of them and have 5 left for the rest of your project, which is what?

Go Up