Go Down

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

floresta

#25
Dec 12, 2012, 01:40 am Last Edit: Dec 12, 2012, 01:42 am by floresta Reason: 1
Quote
LiquidCrystal lcd(7,8,9,6,5,0);


Are you going to keep us in the dark about your code?  For example, are you using the Serial Monitor?

By the way, you tacked this on to an old thread that is marked [SOLVED], not really a good idea.


Don

bluenomad

Thanks guys.  Yes. I'm using the SD card, the Serial Monitor and the RTC. Everything works fine if I leave out the code for the LCD, so I don' t see how pin 4 might be conflicting with my optical sensor.  I also thought that the chipselect was pin 10.  Here is the code.
Code: [Select]
#include "SD.h"
#include <Wire.h>
#include "RTClib.h"
#include <LiquidCrystal.h>

//These define the pin connections of the Arduino. 
//They can be changed but only use digital in 2 or 3 for the Freq pin
#define TSL_FREQ_PIN 2 // output use digital pin2 for interrupt

float fD = 0.1; // Dark frequency
float Re = 2.3; // Irradiance responsivity
float eff475 = 0.113; // Luminous efficiency at 475nm, for dinoflagellate bioluminescence

RTC_DS1307 RTC; // define the Real Time Clock object

#define ECHO_TO_SERIAL   1 // echo data to serial port
#define WAIT_TO_START    0 // Wait for serial input in setup()

// the digital pins that connect to the LEDs
#define redLEDpin 3
#define greenLEDpin 4

// for the data logging shield, we use digital pin 10 for the SD cs line
const int chipSelect = 10;

// the logging file
File logfile;

void error(char *str)
{
  Serial.print("error: ");
  Serial.println(str);
 
  // red LED indicates error
  digitalWrite(redLEDpin, HIGH);
 
  while(1);
}

int timing = 1000; // in milliseconds
volatile unsigned long pulse_cnt = 0;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7,8,9,6,5,0);

void setup() {
   // IF I PUT THE LCD CODE HERE, IT WORKS FINE (see bottom)

  Serial.begin(9600);
  Serial.println();
  Wire.begin();
  RTC.begin();

#if WAIT_TO_START
  Serial.println("Type any character to start");
  while (!Serial.available());
#endif //WAIT_TO_START

  Serial.print("Initializing SD card...");
  // make sure that the default chip select pin is set to
  // output, even if you don't use it:
  pinMode(chipSelect, OUTPUT);
 
  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    return;
  }
  Serial.println("card initialized.");
// PROBLEM CODE IS HERE:
    // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
lcd.setCursor(0, 0);
  // Print a message to the LCD.
lcd.print("LCD not working!");

     


floresta

#27
Dec 12, 2012, 04:19 pm Last Edit: Dec 12, 2012, 04:22 pm by floresta Reason: 1
Quote
Thanks guys.  Yes. I'm using the SD card, the Serial Monitor and the RTC.


It is probably the Serial Monitor and the LCD competing for the use of pin 0.

Don

bluenomad

No. I switched pin 0 around before. Same thing unfortunately. Doesn't make any sense to me. I've looked at all the pins to find which one might conflict with the SPI etc and I'm not using any of those pins. Perhaps pin 4 which is now hardwired unfortunately, is suddenly becoming a problem, tho is was fine before the LCD. Dunno. Thx

floresta

#29
Dec 12, 2012, 09:08 pm Last Edit: Dec 12, 2012, 09:18 pm by floresta Reason: 1
We can only troubleshoot based on the information that you provide, when you withhold information it just wastes time.

You posted code that clearly shows that the LCD is using pin 0 and when asked you told us that you are also using the Serial Monitor.  Since the Serial Monitor always uses pins 0 and 1 this is a clear conflict that could very well result in garbage being displayed on the LCD.

Now you tell us that you "switched pin 0 around" and you got the "Same thing".  What we need to know is
(1) what was the configuration after you switched things
(2) what code was used when you switched things
(3) was the 'garbage' the same garbage as before or was it different
(4) in either case did the garbage resemble what was supposed to be there (same number of characters as expected, same location as expected, etc.)


Quote
I have a shield with combined RTC and SD card.
...
This doesn't seem to be using any pins that conflict, but maybe I'm missing something?

You haven't identified your shield so how can we tell if you are missing something?


Don

Go Up