Im a beginner, and just wanted to make a clock & date + text display on a 16x2 lcd.
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x3F
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
int scroll=0;
int second=0;
int minute=59;
int hour=23;
int day=30;
int month=1;
void setup() {
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.begin(16,2);
lcd.setCursor(0,0);
}
void loop() {
lcd.setCursor(4,0);
lcd.print(hour);
lcd.setCursor(6,0);
lcd.print(":");
lcd.print(minute);
lcd.setCursor(9,0);
lcd.print(":");
lcd.print(second);
lcd.setCursor(5,1);
lcd.print(month);
lcd.setCursor(7,1);
lcd.print(".");
lcd.print(day);
second=second+1;
delay(1000);
if(second == 60){
second=0;
minute=minute+1;
}
if(minute == 60){
minute=0;
hour=hour+1;
}
if(hour == 24){
hour=0;
day=day+1;
}
if(day == 31 && month == 1){
day=0;
month=month+1;
}
if(day == 28 && month == 2){
day=0;
month=month+1;
}
if(day == 31 && month == 3){
day=0;
month=month+1;
}
if(day == 30 && month == 4){
day=0;
month=month+1;
}
if(day == 31 && month == 5){
day=0;
month=month+1;
}
if(day == 30 && month == 6){
day=0;
month=month+1;
}
if(day == 31 && month == 7){
day=0;
month=month+1;
}
if(day == 31 && month == 8){
day=0;
month=month+1;
}
if(day == 30 && month == 9){
day=0;
month=month+1;
}
if(day == 31 && month == 10){
day=0;
month=month+1;
}
if(day == 30 && month == 11){
day=0;
month=month+1;
}
if(day == 31 && month == 12){
day=0;
month=1;
}
lcd.clear();
}
I want to scroll between the two (text and date), but when i use this,
for (int positionCounter = 0; positionCounter < 17; positionCounter++) {
lcd.scrollDisplayRight();
delay(200);
it adds more delay to my clock.
I know, i should use an RTC module, but it is not available for me at the time.
Is there any way to solve this without an RTC module and only with the delay() function?
Sorry for my bad english and thank you.