Pages: [1]   Go Down
Author Topic: Time on a display  (Read 106 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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();
}
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26481
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe the wiring is screwed.
Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe the wiring is screwed.

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

Cincinnati, OH
Offline Offline
God Member
*****
Karma: 49
Posts: 857
I'm not bossy...I just know what you should be doing.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Faraday Member
**
Karma: 100
Posts: 5950
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

that would probably explain it.
Logged

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,
DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Pages: [1]   Go Up
Jump to: