Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Wire.h"
- #include "wiring.c"
- void setup() {
- Wire.begin();
- Wire.beginTransmission(0x68);
- // Start from 0x07 register
- Wire.write(0x07);
- // Alarm 1
- Wire.write(B10000000);
- Wire.write(B10000000);
- Wire.write(B10000000);
- Wire.write(B10000000);
- // Alarm 2
- Wire.write(B10000000);
- Wire.write(B10000000);
- Wire.write(B10000000);
- // Control
- Wire.write(B01000101);
- // Finish
- Wire.endTransmission();
- Serial.begin(9600);
- attachInterrupt(0, herz, FALLING);
- }
- void loop() {
- Wire.beginTransmission(0x68);
- Wire.write(0x00);
- Wire.endTransmission();
- Wire.requestFrom(0x68,3);
- if(Wire.available()) {
- byte secund = Wire.read(); //00h
- byte minut = Wire.read(); //01h
- byte chasov = Wire.read(); //02h
- Serial.print((chasov & B00110000)>>4);
- Serial.print(chasov & B00001111);
- Serial.write(':');
- Serial.print((minut & B11110000)>>4);
- Serial.print(minut & B00001111);
- Serial.write(':');
- Serial.print((secund & B11110000)>>4);
- Serial.print(secund & B00001111);
- Serial.print(":");
- }
- Serial.println (millis() );
- }
- void herz(){
- timer0_millis=0; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement