View difference between Paste ID: 4PrSjXja and beYaDHwj
SHOW: | | - or go back to the newest paste.
1
#include "Wire.h"
2
#include "wiring.c"
3
void setup() {
4
Wire.begin();
5
Wire.beginTransmission(0x68);
6-
Wire.write(0x0E); // Control Register
6+
// Start from 0x07 register
7-
//Wire.write(B01000000); // 1 Hz Out
7+
8-
Wire.write(B00000111); 
8+
// Alarm 1
9
Wire.write(B10000000);
10
Wire.write(B10000000);
11-
Wire.write(0x08);
11+
12
Wire.write(B10000000);
13-
Wire.write(0x09);
13+
// Alarm 2
14
Wire.write(B10000000);
15-
Wire.write(0x0A);
15+
16
Wire.write(B10000000);
17
// Control
18
Wire.write(B01000101);
19
// Finish
20
Wire.endTransmission();
21
Serial.begin(9600);
22
attachInterrupt(0, herz, FALLING);
23
}
24
void loop() {
25
Wire.beginTransmission(0x68);
26
Wire.write(0x00);
27
Wire.endTransmission();
28
Wire.requestFrom(0x68,3);
29
if(Wire.available()) {
30
  byte secund = Wire.read(); //00h
31
  byte minut = Wire.read();  //01h
32
  byte chasov = Wire.read();  //02h
33
  Serial.print((chasov & B00110000)>>4);
34
  Serial.print(chasov & B00001111);
35
  Serial.write(':');
36
  Serial.print((minut & B11110000)>>4);
37
  Serial.print(minut & B00001111);
38
  Serial.write(':');
39
  Serial.print((secund & B11110000)>>4);
40
  Serial.print(secund & B00001111);
41
  Serial.print(":");
42
  }
43
Serial.println (millis() );
44
45
}
46
void herz(){ 
47
timer0_millis=0; }