Advertisement
Guest User

Untitled

a guest
Aug 24th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. #include<LiquidCrystal.h>
  2. #include <Time.h>
  3. #include <Wire.h>
  4. #include <DS1307RTC.h>
  5. #include <Servo.h>
  6.  
  7. #define SERVO_PIN 10
  8.  
  9. LiquidCrystal lcd(2,3,4,5,6,7);
  10. Servo servo; //define object to control servo
  11. int tts[6] = {0, 0, 0, 0, 0, 0}; //define array with time to start
  12.  
  13. void setup()
  14. {
  15. servo.attach(SERVO_PIN);
  16.  
  17. lcd.begin(16,2);
  18. setSyncProvider(RTC.get); // получение сигнала RTC
  19.  
  20. //set date to start moving servo
  21. tts[0] = 32; //sec
  22. tts[1] = 12; //min
  23. tts[2] = 00; //hour
  24. tts[3] = 25; //day
  25. tts[4] = 8; //month
  26. tts[5] = 2016; //year
  27. }
  28.  
  29. void loop()
  30. {
  31. lcd.setCursor(0,1);
  32. if (timeStatus() == timeSet)
  33. {
  34. digitalClockDisplay();
  35. }
  36. else
  37. {
  38. lcd.println("The time has not been set. PleaseruntheTime");// Времени не было установлено. Пожалуйста, запустите время
  39. lcd.println("TimeRTCSetexample, or DS1307RTC SetTimeexample.");// Пример TimeRTCSet, или DS1307RTC пример SetTime
  40. lcd.println();
  41. delay(4000);
  42. }
  43.  
  44. if((second() == tts[0]) && (minute() == tts[1]) && (hour() == tts[2])
  45. && (day() == tts[3]) && (month() == tts[4]) && (year() == tts[5]))
  46. {
  47. servo.write(45);
  48. delay(1000);
  49. servo.write(0);
  50. delay(1000);
  51. servo.write(90);
  52. delay(1000);
  53. servo.write(0);
  54. delay(1000);
  55. }
  56.  
  57. delay(1000);
  58. }
  59.  
  60. void digitalClockDisplay()
  61. {
  62. // цифровой дисплей часов времени
  63. lcd.print(hour());
  64. printDigits(minute());
  65. printDigits(second());
  66. lcd.print(" ");
  67. lcd.print(day());
  68. lcd.print(" ");
  69. lcd.print(month());
  70. lcd.print(" ");
  71. lcd.print(year());
  72. lcd.println();
  73. }
  74.  
  75. void printDigits(int digits) {
  76. // utility function for digital clock display: prints preceding colon and leading 0
  77. lcd.print(":");
  78. if(digits < 10)
  79. lcd.print('0');
  80. lcd.print(digits);
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement