Go Down

Topic: [Solved]correct output on 1 lcd, wrong on another (Read 864 times) previous topic - next topic


Jan 25, 2013, 05:18 pm Last Edit: Jan 25, 2013, 07:04 pm by grendle Reason: 1
hello. im using this display http://www.dfrobot.com/wiki/index.php?title=Arduino_LCD_KeyPad_Shield_(SKU:_DFR0009). i am getting correct output on a scott edwards bpp420 serial lcd, but not on the dfrobot display. example, the first displays the year correctly as 2013, the dfrobot displays 2165. ofcourse the code has been modified to work with each one, and text formats correctly on the dfrobot. original code from 1302 library modified to suit my needs for testing. heres the code for the dfrobot display. thank you for looking and taking a crack at it.

Code: [Select]
#include <LiquidCrystal.h>
#include <stdio.h>
#include <string.h>
#include <DS1302.h>

/* Set the appropriate digital I/O pin connections */
uint8_t CE_PIN   = 11;                                                 // also tried pins 2, 11, 12, wrang the pins out to ensure im landing the right ones
uint8_t IO_PIN   = 12;
uint8_t SCLK_PIN = 13;

/* Create buffers */
char buf[50];
char day[10];

/* Create a DS1302 object */
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void print_time()
 /* Get the current time and date from the chip */
 Time t = rtc.time();

 /* Name the day of the week */
 memset(day, 0, sizeof(day));  /* clear day buffer */
 switch (t.day) {
 case 1:
   strcpy(day, "Sunday");
 case 2:
   strcpy(day, "Monday");
 case 3:
   strcpy(day, "Tuesday");
 case 4:
   strcpy(day, "Wednesday");
 case 5:
   strcpy(day, "Thursday");
 case 6:
   strcpy(day, "Friday");
 case 7:
   strcpy(day, "Saturday");

 //Format the time and date and insert into the temporary buffer
 snprintf(buf, sizeof(buf), "%s %04d-%02d-%02d %02d:%02d:%02d",
 t.yr, t.mon, t.date,
 t.hr, t.min, t.sec);
 // snprintf(buf, sizeof(buf),"%02d:%02d",t.hr,t.min);

 /* Print the formatted string to serial so we can see the time */
 lcd.print(t.yr);                                                                        // <--------here is output
 Serial.print(t.yr);                                                                        //        it prints wrong in the serial window also, but not on the other bpp420 using softserial library

void setup()
  /* Initialize a new chip by turning off write protection and clearing the
  clock halt flag. These methods needn't always be called. See the DS1302
  datasheet for details. */


 // Make a new time object to set the date and time
 // Tuesday, May 19, 2009 at 21:16:37.          
 // Time t(2013, 1, 24, 18, 55, 00, 5);

 // Set the time and date on the chip
 // rtc.time(t);

/* Loop and print the time every second */
void loop()



pins 2, 3, and 11 work. had to ring them out again. counting DO (on the shield) from low to high #2 pin is 5 over, 3 is 6, and 11 is 7th. it works now, ill have to map them all out.

Go Up