Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "Wire.h"
  2. #include "wiring.c"
  3. void setup() {
  4. Wire.begin();
  5. Wire.beginTransmission(0x68);
  6. // Start from 0x07 register
  7. Wire.write(0x07);
  8. // Alarm 1
  9. Wire.write(B10000000);
  10. Wire.write(B10000000);
  11. Wire.write(B10000000);
  12. Wire.write(B10000000);
  13. // Alarm 2
  14. Wire.write(B10000000);
  15. Wire.write(B10000000);
  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; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement