0

The problem is that the Liquid Crystal LCD display only prints "f" on every row and every column.

When I tell it to print something, then the display prints "f" on every square(row, column) for a brief second, then each square shows three white bars stacked up parallel to each other (quite like an "=" sign except that there's one more bar on top").

I am also using a tmrpcm library, so I'm guessing that interrupts might have to do with this, but I have no idea how to solve the problem.

The link to the tmrpcm library is as follows: https://github.com/TMRh20/TMRpcm

Thank you so much. I need to get this done by tomorrow 8 A.M., so I'm pretty desperate.

#include <LiquidCrystal.h>
#include <SD.h>                      // need to include the SD library
//#define SD_ChipSelectPin 53  //example uses hardware SS pin 53 on Mega2560
#define SD_ChipSelectPin 10  //using digital pin 4 on arduino nano 328
#include <TMRpcm.h>           //  also need to include this library...

TMRpcm tmrpcm;   // create an object for use in this sketch
char mychar;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

volatile int pauseOnOff;

void setup(){

  tmrpcm.speakerPin = 9; //11 on Mega, 9 on Uno, Nano, etc

  if (!SD.begin(SD_ChipSelectPin)) {  // see if the card is present and can be initialized:
    Serial.println("SD fail");  
    return;   // don't do anything more if not
  }
  else{
    Serial.println("success!");
  }

  tmrpcm.play("Closer.wav");

  lcd.begin(16, 2);

  lcd.print("hello, world!");
}

void loop(){

}
2
  • If the problem is “something to do with interrupts” you will need to show some code for the problem to be diagnosed. Please edit your question to include a Minimal, Complete, and Verifiable example of code. On the other hand, it may be a wiring problem. In that case, edit your question to include a circuit diagram and parts list. Apr 9, 2017 at 2:58
  • Thank you, but I can confirm that the wiring is not the problem by excluding the tmrpcm library and confirming that the display works correctly. Furthermore, I do not know how the tmrpcm library works...I've been studying for it for a few weeks but I still don't grasp how it works.
    – Daniel
    Apr 9, 2017 at 3:10

1 Answer 1

2

I don't know the source of the problem, but here are a few things that might help diagnose where the problem begins or what it is due to.

(a) To track execution progress, and detect which statement, if any, ruins LCD operation: Create a routine to display current line number in code to LCD and Serial; make a macro ss to use for invoking that routine; invoke the macro before and after each line containing a tmrpcm action by calls like ss;. See following example.

void shoLine(int line) {
  Serial.println(line);
  lcd.home ();     // Set cursor to 0,0
  lcd.print(line);
  lcd.print(' ');
  delay(200);  // /Delay long enough to see stuff appear
}
#define ss shoLine(__LINE__)

Note: Move lcd.begin(16, 2); to be the first statement in setup() when using this method of debugging.

(b) If you find that the first few LCD calls are ok and then LCD output stops working, try turning off interrupts during LCD output. That is, put a cli() or noInterrupts() call before an lcd.print(), and an sei() or interrupts() after it, and see if it then works. If so, that might serve as a last-ditch workaround. (I don't know whether LCD output routines use any interrupts; I doubt they do; but if they do, this method won't work.)

(c) If the LCD doesn't display correctly at all, even before the first tmrpcm action, it may be that the combination of tmrpcm with other code is using too much memory. Carefully check the memory-usage reports when you compile your sketch.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.