trialex has not received any patches yet... send trialex a patch!

7
comments
|
Add Comment
|
#include <Wire.h>// TWI (I2C) sketch to communicate with the DS1307 Real Time Clockvoid setup(){ Wire.begin(); // join i2c bus (address optional for master) Serial.begin(9600); // program the time & enable clock (each hex digit corresponds to one clock digit) Wire.beginTransmission(0x68); Wire.send(0); Wire.send(0x00); //seconds Wire.send(0x30); //minutes Wire.send(0x80 | 0x21); //hours (24hr time) Wire.endTransmission();}void loop(){ Wire.beginTransmission(0x68); Wire.send(0); Wire.endTransmission(); Wire.requestFrom(0x68, 3); byte secs = Wire.receive(); byte mins = Wire.receive(); byte hrs = Wire.receive(); Serial.print(hrs,HEX); Serial.print(":"); Serial.print(mins,HEX); Serial.print(":"); Serial.println(secs,HEX); delay(1000); //wait a second before next output} ![]() |

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.