Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- //#include <LiquidCrystal_I2C.h>
- //LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // initializes the LCM1602 IIC V1 (LCD module)
- // 0x27 is the I2C address. This address might be different.
- #include <LiquidCrystal.h>
- #include <ThreeWire.h>
- #include <RtcDS1302.h>
- ThreeWire myWire(12,10,8); // IO, SCLK, CE
- RtcDS1302<ThreeWire> Rtc(myWire);
- LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
- void setup() {
- lcd.begin(16, 2);
- lcd.setCursor(0,0);
- lcd.write("test 1 2 3");
- #define countof(a) (sizeof(a) / sizeof(a[0]))
- Rtc.Begin();
- RtcDateTime compiled = RtcDateTime(__DATE__, __TIME__);
- Rtc.SetDateTime(compiled);
- // lcd.begin(16, 2); // begins connection to the LCD module
- // lcd.backlight(); // turns on the backlight
- Serial.begin(9600);
- }
- void loop() {
- // value_A0 = analogRead(IN_A0); // reads the analog input from the IR distance sensor
- // value_D0 = digitalRead(IN_D0);// reads the digital input from the IR distance sensor
- RtcDateTime now = Rtc.GetDateTime();
- printDateTime(now);
- // char buffer[5] = "";
- // sprintf(buffer, "A0 = %04d", val0);
- // Serial.println(value_A0);
- // Serial.println("digital " + value_D0);
- // Serial.println(value_A0,value_D0);
- Serial.print("test");
- // lcd.setCursor(0, 0); // sets the cursor of the LCD module to the first line
- // lcd.print("A0:");
- // lcd.setCursor(3, 0); // sets the cursor of the LCD module to the fourth character
- // lcd.print(value_A0); // prints analog value on the LCD module
- //
- // lcd.setCursor(0, 1); // sets the cursor of the LCD module to the first line
- // lcd.print("D0:");
- // lcd.setCursor(3, 1); // sets the cursor of the LCD module to the fourth character
- // lcd.print(value_D0); // prints digital value on the LCD module
- delay(1000);
- }
- void printDateTime(const RtcDateTime& dt)
- {
- char datestring[11];
- char timestring[9];
- snprintf_P(datestring,
- countof(datestring),
- PSTR("%02u/%02u/%04u"),
- dt.Month(),
- dt.Day(),
- dt.Year());
- lcd.setCursor(0,0);
- lcd.print(datestring);
- snprintf_P(timestring,
- countof(timestring),
- PSTR("%02u:%02u:%02u"),
- dt.Hour(),
- dt.Minute(),
- dt.Second() );
- lcd.setCursor(0,1);
- lcd.print(timestring);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement