Guest User

Untitled

a guest
Nov 17th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #include "Wire.h"
  2. #include "wiring.c"
  3. void setup() {
  4. Wire.begin();
  5. Wire.beginTransmission(0x68);
  6. Wire.write(0x0E); // Control Register
  7. //Wire.write(B01000000); // 1 Hz Out
  8. Wire.write(B00000111);
  9. Wire.write(0x07);
  10. Wire.write(B10000000);
  11. Wire.write(0x08);
  12. Wire.write(B10000000);
  13. Wire.write(0x09);
  14. Wire.write(B10000000);
  15. Wire.write(0x0A);
  16. Wire.write(B10000000);
  17. Wire.endTransmission();
  18. Serial.begin(9600);
  19. attachInterrupt(0, herz, FALLING);
  20. }
  21. void loop() {
  22. Wire.beginTransmission(0x68);
  23. Wire.write(0x00);
  24. Wire.endTransmission();
  25. Wire.requestFrom(0x68,3);
  26. if(Wire.available()) {
  27. byte secund = Wire.read(); //00h
  28. byte minut = Wire.read(); //01h
  29. byte chasov = Wire.read(); //02h
  30. Serial.print((chasov & B00110000)>>4);
  31. Serial.print(chasov & B00001111);
  32. Serial.write(':');
  33. Serial.print((minut & B11110000)>>4);
  34. Serial.print(minut & B00001111);
  35. Serial.write(':');
  36. Serial.print((secund & B11110000)>>4);
  37. Serial.print(secund & B00001111);
  38. Serial.print(":");
  39. }
  40. Serial.println (millis() );
  41.  
  42. }
  43. void herz(){
  44. timer0_millis=0; }
Advertisement
Add Comment
Please, Sign In to add comment