Go Down

Topic: Time on a display (Read 135 times) previous topic - next topic

Markrose

Hello all,
I am trying to make the time and date show up on my 16x2 display. For some reason though, it throws up random crazy characters on the display instead of the numbers. I've included the program code. I have an Arduino Leonardo, hooked up to a 16x2 LCD and a DS1307 RTC. The time on the serial monitor is displayed just fine, it's the LCD that's the issue.

CODE:

Code: [Select]

#include <LiquidCrystal.h>
#include <Wire.h>
#include "RTClib.h"

RTC_DS1307 rtc;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup ()
{
#ifdef AVR
  Wire.begin();
#else
  Wire1.begin();
#endif
  rtc.begin();
  lcd.clear();
    rtc.adjust(DateTime(__DATE__, __TIME__));
  }


void loop () {
    DateTime now = rtc.now();
    lcd.setCursor(0,0);
    lcd.print("Date: ");
    lcd.setCursor(7,0);
    lcd.print(now.month(), DEC);
    lcd.setCursor(10,0);
    lcd.print("/");
    lcd.setCursor(11,0);
    lcd.print(now.day(), DEC);
    lcd.setCursor(1,0);
    lcd.print("Time: ");
    lcd.setCursor(1,7);
    lcd.print(now.hour(), DEC);
    lcd.setCursor(1,10);
    lcd.print(":");
    lcd.setCursor(1,11);
    lcd.print(now.minute(), DEC);
   
   
   
    delay(1000);
    lcd.clear();
}

AWOL

Maybe the wiring is screwed.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Markrose


Maybe the wiring is screwed.


It can't be so, as another program I have will run fine on the display with no rewiring.

econjack

Don't the values returned have to be converted from BCD back to decimal??

raschemmel

that would probably explain it.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Go Up