Achso es ist ein mega 2560
So hier das prog:
// DS1307_LCD (C)2010 Henning Karlsen
// web: Electronics - Henning Karlsen
//
// A quick demo of how to use my DS1307-library to make a quick
// clock using a DS1307 and a 16x2 LCD.
//
// I assume you know how to connect the DS1307 and LCD.
// DS1302: SDA pin -> Arduino Digital 4
// SCL pin -> Arduino Digital 5
// LCD: DB7 -> Arduino Digital 6
// DB6 -> Arduino Digital 7
// DB5 -> Arduino Digital 8
// DB4 -> Arduino Digital 9
// E -> Arduino Digital 10
// RS -> Arduino Digital 11
#include <LiquidCrystal.h>
#include <DS1307.h>
// Init the DS1307
DS1307 rtc(4, 5);
DS1307_LCD:21: error: 'DS1307' does not name a type
DS1307_LCD.pde: In function 'void setup()':
DS1307_LCD:29: error: 'rtc' was not declared in this scope
DS1307_LCD:35: error: 'SUNDAY' was not declared in this scope
DS1307_LCD:40: error: 'SQW_RATE_1' was not declared in this scope
DS1307_LCD.pde: In function 'void loop()':
DS1307_LCD:48: error: 'rtc' was not declared in this scope
DS1307_LCD:52: error: 'FORMAT_SHORT' was not declared in this scope
// Init the LCD
LiquidCrystal lcd(11, 10, 9, 8, 7, 6);
void setup()
{
// Set the clock to run-mode
rtc.halt(false);
// Setup LCD to 16x2 characters
lcd.begin(16, 2);
// The following lines can be commented out to use the values already stored in the DS1307
rtc.setDOW(SUNDAY); // Set Day-of-Week to SUNDAY
rtc.setTime(12, 0, 0); // Set the time to 12:00:00 (24hr format)
rtc.setDate(3, 10, 2010); // Set the date to October 3th, 2010
// Set SQW/Out rate to 1Hz, and enable SQW
rtc.setSQWRate(SQW_RATE_1);
rtc.enableSQW(true);
}
void loop()
{
// Display time centered on the upper line
lcd.setCursor(4, 0);
lcd.print(rtc.getTimeStr());
// Display abbreviated Day-of-Week in the lower left corner
lcd.setCursor(0, 1);
lcd.print(rtc.getDOWStr(FORMAT_SHORT));
// Display date in the lower right corner
lcd.setCursor(6, 1);
lcd.print(rtc.getDateStr());
// Wait one second before repeating
delay (1000);
}