Displaying time on a lcd using rtc

Hi I have made a program to open my shutters in the morning. I need to display the time on a lcd screen can anybody write the code for me any help will be appreciated :slight_smile:

#include <Wire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <Servo.h>

Servo myservo;

int pos = 0;

void setup()
{
Serial.begin(9600);
while (!Serial) ; // wait for serial
delay(200);
Serial.println(“DS1307RTC Read Test”);
Serial.println("-------------------");

myservo.attach(9);
myservo.write(0);
}

void loop()
{
tmElements_t tm;

if (RTC.read™)
{
Serial.print("Ok, Time = “);
print2digits(tm.Hour);
Serial.write(’:’);
print2digits(tm.Minute);
Serial.write(’:’);
print2digits(tm.Second);
Serial.print(”, Date (D/M/Y) = ");
Serial.print(tm.Day);
Serial.write(’/’);
Serial.print(tm.Month);
Serial.write(’/’);
Serial.print(tmYearToCalendar(tm.Year));
Serial.println();

if((tm.Hour==14)&&(tm.Minute==10)&&(tm.Second==00))
{
myservo.write(180);

for(int i=0 ;i<30 ;i++)
{
delay(1000);
}
myservo.write(0);
}
}

else
{
if (RTC.chipPresent())
{
Serial.println(“The DS1307 is stopped. Please run the SetTime”);
Serial.println(“example to initialize the time and begin running.”);
Serial.println();
}
else
{
Serial.println(“DS1307 read error! Please check the circuitry.”);
Serial.println();
}
delay(9000);
}
delay(1000);
}

void print2digits(int number)
{
if (number >= 0 && number < 10)
{
Serial.write(‘0’);
}
Serial.print(number);
}

What LCD? Can't even start till we see a data sheet.

If we were to assume that all you require is time and date to be displayed, a 1602 would probably be suitable? In which case, all you would need to do would be change the Serial.print to Lcd.print for the time and date statements (and cursor position settings).

Regards,

Graham