Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include <LiquidCrystal.h>
  2.  
  3. int S = 59; // count seconds
  4. int M = 59; // count minutes
  5. int H = 23; // count hours
  6. //initialize the library with the numbers of the interface pins
  7. LiquidCrystal lcd(4,6,10,11,12,13); // pins connected to LCD
  8.  
  9. void setup()
  10. {
  11. lcd.begin(16,2);//set up the LCD's number of columns and rows
  12. }
  13. void loop()
  14. {
  15. lcd.setCursor(1,0);
  16. lcd.print ("Tutorial45.com");
  17. lcd.setCursor(6,1);
  18. lcd.print(":");
  19. lcd.setCursor(9,1);
  20. lcd.print(":");
  21.  
  22. S--;
  23. delay(1000);
  24.  
  25. if(S<0)
  26. {
  27. M--;
  28. S=59;
  29. }
  30. if(M<0)
  31. {
  32. H--;
  33. M=59;
  34. }
  35. if(H<0) { H=23; M=59; S=59; } if(M>9)
  36. {
  37. lcd.setCursor(7,1);
  38. lcd.print(M);
  39. }
  40. else
  41. {
  42. lcd.setCursor(7,1);
  43. lcd.print("0");
  44. lcd.setCursor(8,1);
  45. lcd.print(M);
  46. lcd.setCursor(9,1);
  47. lcd.print(":");
  48. }
  49.  
  50. if(S>9)
  51. {
  52. lcd.setCursor(10,1);
  53. lcd.print(S);
  54. }
  55. else
  56. {
  57. lcd.setCursor(10,1);
  58. lcd.print("0");
  59. lcd.setCursor(11,1);
  60. lcd.print(S);
  61. lcd.setCursor(12,1);
  62. lcd.print(" ");
  63. }
  64.  
  65. if(H>9)
  66. {
  67. lcd.setCursor(4,1);
  68. lcd.print (H);
  69. }
  70. else
  71. {
  72. lcd.setCursor(4,1);
  73. lcd.print("0");
  74. lcd.setCursor(5,1);
  75. lcd.print(H);
  76. lcd.setCursor(6,1);
  77. lcd.print(":");
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement