I downloaded the library DS1307 created by Henning Karlsen. But I cannot compile it. It Says "DS1307 Does not name a type"
Error:
DS1307_Serial_Easy:14: error: 'DS1307' does not name a type
DS1307_Serial_Easy.pde: In function 'void setup()':
DS1307_Serial_Easy:19: error: 'rtc' was not declared in this scope
DS1307_Serial_Easy:25: error: 'SUNDAY' was not declared in this scope
DS1307_Serial_Easy.pde: In function 'void loop()':
DS1307_Serial_Easy:33: error: 'rtc' was not declared in this scope
here's the code:
// DS1307_Serial_Easy (C)2010 Henning Karlsen
// web: Electronics - Henning Karlsen
//
// A quick demo of how to use my DS1307-library to
// quickly send time and date information over a serial link
//
// I assume you know how to connect the DS1307.
// DS1307: SDA pin -> Arduino Digital 4
// SCL pin -> Arduino Digital 5
#include <DS1307.h>
// Init the DS1307
DS1307 rtc(4, 5);
void setup()
{
// Set the clock to run-mode
rtc.halt(false);
// Setup Serial connection
Serial.begin(9600);
// 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
}
// Aquire data from the RTC chip in BCD format
// refresh the buffer
void DS1307::read(void)
{
// use the Wire lib to connect to tho rtc
// reset the resgiter pointer to zero
Wire.beginTransmission(DS1307_CTRL_ID);
Wire.send(0x00);
Wire.endTransmission();
// request the 7 bytes of data (secs, min, hr, dow, date. mth, yr)
Wire.requestFrom(DS1307_CTRL_ID, 7);
for(int i=0; i<7; i++)
{
// store data in raw bcd format
rtc_bcd*=Wire.receive();* } } // update the data on the IC from the bcd formatted data in the buffer void DS1307::save(void) { Wire.beginTransmission(DS1307_CTRL_ID); Wire.send(0x00); // reset register pointer for(int i=0; i<7; i++) { Wire.send(rtc_bcd*);
_}_ Wire.endTransmission();
_}_
_// PUBLIC FUNCTIONS*_ void DS1307::get(int *rtc, boolean refresh) // Aquire data from buffer and convert to int, refresh buffer if required { if(refresh) read(); for(int i=0;i<7;i++) // cycle through each component, create array of data { _ rtc*=get(i, 0); } } int DS1307::get(int c, boolean refresh) // aquire individual RTC item from buffer, return as int, refresh buffer if required { if(refresh) read(); int v=-1; switch(c) {_ case DS1307_SEC: v=(10((rtc_bcd[DS1307_SEC] & DS1307_HI_SEC)>>4))+(rtc_bcd[DS1307_SEC] & DS1307_LO_BCD); * break;* case DS1307_MIN: v=(10*((rtc_bcd[DS1307_MIN] & DS1307_HI_MIN)>>4))+(rtc_bcd[DS1307_MIN] & DS1307_LO_BCD); * break;* case DS1307_HR: v=(10*((rtc_bcd[DS1307_HR] & DS1307_HI_HR)>>4))+(rtc_bcd[DS1307_HR] & DS1307_LO_BCD); * break;* case DS1307_DOW: * v=rtc_bcd[DS1307_DOW] & DS1307_LO_DOW; _ break;_ case DS1307_DATE: v=(10((rtc_bcd[DS1307_DATE] & DS1307_HI_DATE)>>4))+(rtc_bcd[DS1307_DATE] & DS1307_LO_BCD); * break;* case DS1307_MTH: v=(10*((rtc_bcd[DS1307_MTH] & DS1307_HI_MTH)>>4))+(rtc_bcd[DS1307_MTH] & DS1307_LO_BCD); * break;* case DS1307_YR: v=(10*((rtc_bcd[DS1307_YR] & DS1307_HI_YR)>>4))+(rtc_bcd[DS1307_YR] & DS1307_LO_BCD)+DS1307_BASE_YR; * break;* } // end switch return v; } void DS1307::set(int c, int v) // Update buffer, then update the chip { switch(c) { case DS1307_SEC: * if(v<60 && v>-1)* * {* * //preserve existing clock state (running/stopped)* * int state=rtc_bcd[DS1307_SEC] & DS1307_CLOCKHALT; rtc_bcd[DS1307_SEC]=state | ((v / 10)<<4) + (v % 10); _ } break; case DS1307_MIN: if(v<60 && v>-1) {_ rtc_bcd[DS1307_MIN]=((v / 10)<<4) + (v % 10); _ } break; case DS1307_HR: // TODO : AM/PM 12HR/24HR*
* if(v<24 && v>-1) {_ rtc_bcd[DS1307_HR]=((v / 10)<<4) + (v % 10); _ } break; case DS1307_DOW: if(v<8 && v>-1) {_ rtc_bcd[DS1307_DOW]=v; _ } break; case DS1307_DATE: if(v<31 && v>-1) {_ rtc_bcd[DS1307_DATE]=((v / 10)<<4) + (v % 10); _ } break; case DS1307_MTH: if(v<13 && v>-1) {_ rtc_bcd[DS1307_MTH]=((v / 10)<<4) + (v % 10); _ } break; case DS1307_YR: if(v<13 && v>-1) {_ rtc_bcd[DS1307_YR]=((v / 10)<<4) + (v % 10); _ } break; } // end switch* save(); } void DS1307::stop(void) {
* // set the ClockHalt bit high to stop the rtc*
* // this bit is part of the seconds byte* * rtc_bcd[DS1307_SEC]=rtc_bcd[DS1307_SEC] | DS1307_CLOCKHALT;*
* save(); } void DS1307::start(void) { // unset the ClockHalt bit to start the rtc*
* // TODO : preserve existing seconds* * rtc_bcd[DS1307_SEC]=0;*
* save(); }*_
UKHeliBob:
Read this Installing Arduino libraries
Is the DS1307 library in the correct folder for your Operating System and does it have the correct name ?
I just read the Libraries installation. And my library was properly installed and correct. In fact my other downloaded libraries work.