Go Down

Topic: Interfacing Sparkfun RTC Module with Lilypad (Read 531 times) previous topic - next topic

CRAY-4 Linux

I am working on keeping time with this rtc module http://www.sparkfun.com/products/99 with a lilypad and this code isnt working for me
Code: [Select]
#include "Wire.h"
#define DS1307_ADDRESS 0x68

void setup(){

void loop(){

void setDateTime(){

 byte second =      45; //0-59
 byte minute =      40; //0-59
 byte hour =        0; //0-23
 byte weekDay =     2; //1-7
 byte monthDay =    1; //1-31
 byte month =       3; //1-12
 byte year  =       11; //0-99

 Wire.send(0); //stop Oscillator


 Wire.send(0); //start



byte decToBcd(byte val){
// Convert normal decimal numbers to binary coded decimal
 return ( (val/10*16) + (val%10) );

byte bcdToDec(byte val)  {
// Convert binary coded decimal to normal decimal numbers
 return ( (val/16*10) + (val%16) );

void printDate(){

 // Reset the register pointer

 Wire.requestFrom(DS1307_ADDRESS, 7);

 int second = bcdToDec(Wire.receive());
 int minute = bcdToDec(Wire.receive());
 int hour = bcdToDec(Wire.receive() & 0b111111); //24 hour time
 int weekDay = bcdToDec(Wire.receive()); //0-6 -> sunday - Saturday
 int monthDay = bcdToDec(Wire.receive());
 int month = bcdToDec(Wire.receive());
 int year = bcdToDec(Wire.receive());

 //print the date EG   3/1/11 23:59:59
 Serial.print(" ");


i have it hooked up to analog pins A4 and A5 and i am not quite familiar with the Wire library  :(

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131