SHARE
TWEET

Untitled

a guest Apr 25th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Wire.h>
  2. #include "RTClib.h"
  3. #include <LiquidCrystal_I2C.h>
  4.  
  5. LiquidCrystal_I2C lcd(0x3f,16,2);
  6. RTC_DS1307 RTC;
  7. char stringaDataCompleta[20];
  8. char stringaData[10];
  9. char stringaOra[10];
  10. char days[7][12]={"Dom","Lun","Mar","Mer","Gio","Ven","Sab"};
  11.  
  12. void setup () {
  13. Wire.begin(); // Inicia el puerto I2C
  14. RTC.begin(); // Inicia la comunicaci¢n con el RTC
  15. //RTC.adjust(DateTime(__DATE__, __TIME__)); // Aggiustare ORADATA
  16.  
  17. Serial.begin(9600);
  18.  lcd.init();
  19.  lcd.backlight();
  20.  lcd.clear();
  21.  
  22. }
  23. void loop(){
  24. DateTime now = RTC.now(); // Valorizzo RTC
  25. sprintf(stringaDataCompleta,"%02d/%02d/%d %02d/%02d/%02d",days[now.dayOfTheWeek()],now.day(),now.month(),now.year(),now.hour(),now.minute(),now.second());
  26. sprintf(stringaData,"%02d %02d/%02d/%d ",days[now.dayOfTheWeek()],now.day(),now.month(),now.year());
  27. sprintf(stringaOra,"%02d:%02d:%02d",now.hour(),now.minute(),now.second());
  28. //Serial.println(stringaDataCompleta);
  29. Serial.print(days[now.dayOfTheWeek()]);
  30.     Serial.print(' ');
  31.     Serial.print(now.day(), DEC);
  32.     Serial.print('/');
  33.     Serial.print(now.month(), DEC);
  34.     Serial.print('/');
  35.     Serial.print(now.year(), DEC);
  36.     Serial.print(' ');
  37.     Serial.print(now.hour(), DEC);
  38.     Serial.print(':');
  39.     Serial.print(now.minute(), DEC);
  40.     Serial.print(':');
  41.     Serial.print(now.second(), DEC);
  42.     Serial.println();
  43.  
  44. lcd.setCursor(0,0);
  45. //lcd.print(days[now.dayOfTheWeek()]);
  46. //lcd.print("  ");
  47. //lcd.print(now.day(), DEC);
  48. //lcd.print(":");
  49. //lcd.print(now.month(), DEC);
  50. //lcd.print(":");
  51. //lcd.print(now.year(), DEC);
  52.  
  53. lcd.print(stringaData);
  54.  
  55. lcd.print(" ");
  56. lcd.setCursor(0,1);
  57. lcd.print("Tim: ");
  58. lcd.print(stringaOra);
  59.  
  60. delay(1000);
  61. //lcd.clear();
  62. lcd.setCursor(0,0);
  63. lcd.print("               ");
  64. lcd.setCursor(0,1);
  65. lcd.print("               ");
  66.  
  67. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top