weird lcd bars after printing

I am working on automating my aquarium with an arduino. I want to include an lcd to see the status of the arduino. everything works alright except I am getting weird bars after my printing? I attached the code and a picute of the bars. I am using this lcd http://www.amazon.com/SainSmart-Module-Arduino-Board-White/dp/B003B22UR0/ref=sr_1_2?ie=UTF8&qid=1433077977&sr=8-2&keywords=sainsmart+lcd

//these are for the alarm portion
#include <TimeAlarms.h>
#include <Time.h>
//these are for the lcd portion
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR 0x27
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7

LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);


void setup()
{
//these are for the alarm portion
  Serial.begin(9600);
  setTime(8,29,55,5,28,15); // set time to whatever
  // create the alarms 
  Alarm.alarmRepeat(8,30,00, ActinicONam);  // 8:30am every day actinic lights on
  Alarm.alarmRepeat(8,30,05, ActinicOFFam);  // 9:29am every day actinic lights off
  Alarm.alarmRepeat(8,30,10, DaytimeON);  // 9:30am every day daytime lights on
  Alarm.alarmRepeat(8,30,15, PowerheadOFFam);  // 9:59am every day powerhead off
  Alarm.alarmRepeat(8,30,20, FeedAM);  // 10:00am every day feed fish
  Alarm.alarmRepeat(8,30,25, PowerheadONam);  // 10:05am every day powerhead on
  Alarm.alarmRepeat(8,30,30, PowerheadOFFpm);  // 4:59pm every day powerhead off
  Alarm.alarmRepeat(8,30,35, FeedPM);  // 5:00pm every day feed fish
  Alarm.alarmRepeat(8,30,40, PowerheadONpm);  // 5:05pm every day powerhead on
  Alarm.alarmRepeat(8,30,45, DaytimeOFF);  // 5:29pm every day daytime lights off
  Alarm.alarmRepeat(8,30,50, ActinicONpm);  // 5:30pm every day actinic lights on
  Alarm.alarmRepeat(8,30,55, ActinicOFFpm);  // 8:30am every day actinic lights off
//these are for the relay board
  pinMode(9, OUTPUT);  //actinic lights relay (channel 1)
  pinMode(10, OUTPUT);  //daytime lights relay (channel 2)
  pinMode(11, OUTPUT);  //powerhead relay (channel 3)
  pinMode(12, OUTPUT);  //feeder relay (channel 4)(soon to be changed to servo or stepper)
//these are for the relay board
  digitalWrite(9, LOW);  //start with actinic lights off
  digitalWrite(10, LOW);  //start with daytime lights off
  digitalWrite(11, HIGH);  //start with powerhead on
  digitalWrite(12, LOW);  //do not feed yet
//these are for the lcd portion
  lcd.begin (20,4,LCD_5x8DOTS);
  lcd.setCursor(0,2);  
  lcd.print("Status: ACTIVE");
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);

}

void  loop(){  
  lcd.setBacklight(HIGH);
  digitalClockDisplay();
  Alarm.delay(1000); // wait 30 seconds between clock display
}

// functions to be called when an alarm triggers:
void ActinicONam(){ 
  lcd.setCursor(0,0);  
  lcd.println("Actinic lights on!");
  digitalWrite(9, HIGH);    
}

void ActinicOFFam(){
  lcd.setCursor(0,0);  
  lcd.println("Actinic lights off!"); 
  digitalWrite(9, LOW);  
}

void DaytimeON(){
  lcd.setCursor(0,0); 
  lcd.println("Daytime lights on!");  
  digitalWrite(10, HIGH);  
}

void PowerheadOFFam(){
  lcd.setCursor(0,0); 
  lcd.println("Prepare for feeding.");
  digitalWrite(11, LOW);  
}

void FeedAM(){  
  lcd.setCursor(0,0);
  lcd.println("Fish are fed!");  
  digitalWrite(12, HIGH);
  delay(1000);
  digitalWrite(12, LOW);  
}

void PowerheadONam(){ 
  lcd.setCursor(0,0); 
  lcd.println("Ocean stirring");
  digitalWrite(11, HIGH);  
}

void PowerheadOFFpm(){
  lcd.setCursor(0,0); 
  lcd.println("Prepare for feeding.");
  digitalWrite(11, LOW);  
}

void FeedPM(){
  lcd.setCursor(0,0); 
  lcd.println("Fish are fed!");  
  digitalWrite(12, HIGH);
  delay(1000);
  digitalWrite(12, LOW);  
}

void PowerheadONpm(){
  lcd.setCursor(0,0); 
  lcd.println("Ocean stirring");
  digitalWrite(11, HIGH);  
}

void DaytimeOFF(){
  lcd.setCursor(0,0); 
  lcd.println("Daytime lights off!");  
  digitalWrite(10, LOW);  
}

void ActinicONpm(){
  lcd.setCursor(0,0); 
  lcd.println("Actinic lights on!");
  digitalWrite(9, HIGH);    
}

void ActinicOFFpm(){
  lcd.setCursor(0,0); 
  lcd.println("Actinic lights off!"); 
  digitalWrite(9, LOW);  
}


void digitalClockDisplay()
{
  // digital clock display of the time
  lcd.setCursor(0,1);
  lcd.print(hour());
  printDigits(minute());
  printDigits(second());
  lcd.println(); 
}

void printDigits(int digits)
{
  lcd.print(":");
  if(digits < 10)
    lcd.print('0');
  lcd.print(digits);
}

Any time I see the words LCD, weird, and print in the topic heading I immediately look for an lcd.println() statement in the code.

Look up the documentation for this function and you will be able to determine why it produces weird lcd bars.

Hint: You won't find any documentation.

Don

Just a random wild guess from a casual observer...... it don't like char(0x0d) or char (0x0a) ?

My favourite guess though, I don't like anything with the word 'sainsmart' in it.....

Regards,

Graham

These displays do not deal with the and control codes the way one would expect, mainly because they were not designed to be used as a computer terminal.

The displays treat those ASCII codes just as they do every other ASCII code, as an address into the display memory. In this case they access the foldback (redundant) addresses for two of the custom characters and if you haven't programmed those characters you get quasi random results.

Don

ghlawrence2000:
My favourite guess though, I don't like anything with the word 'sainsmart' in it.....

In this case it is harmless, the only concern being the total lack of useful information on that Amazon page - which fails to mention that this is a display with an I2C backpack already fitted. Clearly if you look at the pictures, that is the case, but it would not tbe the first time the pictures were misleading.

The board and backpack are bog-standard items; all over eBay (and likely much cheaper); kidsoccer78 has clearly admirably managed to surmount the installation of the proper LiquidCrystal_I2C libraries and determine the correct constructor for this display. Well done!

Yes, the LCD is merely displaying the corresponding characters for CR and LF (curiously, the same). The question is - why does a lcd.println() function exist in the library if it is not written to perform the function that would be expected in this particular case? It should have been removed if it could not be actually implemented.

The question is - why does a lcd.println() function exist in the library if it is not written to perform the function that would be expected in this particular case? It should have been removed if it could not be actually implemented.

It doesn't exist in the library, which is why it is not documented. Its use doesn't create an error message either for reasons that Bill (bperrybap) has explained in the past. Look here:

http://forum.arduino.cc/index.php?topic=102266.20

http://forum.arduino.cc/index.php?topic=128055.10

Don

floresta:
It doesn't exist in the library, which is why it is not documented. Its use doesn't create an error message either for reasons that Bill (bperrybap) has explained in the past.

And (after spending considerable time reading all that,) Bill agreed with me! :grinning:

I agree as well especially since the problem can be fixed with one line of code. I wouldn't worry about the resulting 'strange compiler error' since it seems that most of the error messages are a bit obscure anyway.

Even a mention of the fact that the function is not supported in the LiquidCrystal documentation would be better than just ignoring the problem.

Don

Yeah, it is a bit of a sticky situation in that the Print class expects basic new line processing to be supported and the stock LiquidCrystal library as well as many of the other hd44780 based libraries are very simplistic and don't support any newline processing.
(I have seen one hd44780 library that did support line wrapping, scrolling, and new line processing - including for both hd44780 scroll directions)

Eventually I'm going to make a new hd44780 library suite available that will solve many of the issues like this that folks are experiencing as well as make i2c backpacks much easier to configure and use.

I've also done some second generation guesser/auto-detect code that is much smarter and can automagically successfully locate and identify and self configure for most of the i2c to hd44780 backpacks.

Bad new is, it isn't ready yet and I've got several other things ahead of it in the pipeline.

--- bill