New year countdown timer problem on 16x2 lcd

Hello, I am new to arduino (got it a week ago), and I am making an arduino uno project for the new year, I am trying to make a countdown timer that starts when its 30 seconds to the new year, I have a 16x2 lcd and I set a time and date to show up on the first line of the lcd and and tried to to make the countdown timer to appear on the second line, but all i found are scripts that make a countdown when pressing a button or setting time on the lcd, and I couldn’t find scripts that I can put into my script, this is my script: BTW sorry for my english

#include <LiquidCrystal.h>
#include <TimeLib.h>

#define TIME_HEADER  "T"   // Header tag for serial time sync message
#define TIME_REQUEST  7    // ASCII bell character requests a time sync message 

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
unsigned long prevMillis;
int count = 30;

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  while (!Serial) ; // Needed for Leonardo only
  pinMode(13, OUTPUT);
  setSyncProvider( requestSync);  //set function to call when sync required
  Serial.println("Waiting for sync message");
  //lcd.print("hello, world!");

void loop() {
  if (Serial.available()) {
  if (timeStatus()!= timeNotSet) {
  if (timeStatus() == timeSet) {
    digitalWrite(13, HIGH); // LED on if synced
  } else {
    digitalWrite(13, LOW);  // LED off if needs refresh
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 0);

void digitalClockDisplay(){
  // digital clock display of the time
  lcd.setCursor(9, 0);
  Serial.print(" ");
  Serial.print(" ");
  Serial.print(" ");

void printDigits(int digits){
  // utility function for digital clock display: prints preceding colon and leading 0
  if(digits < 10)

void processSyncMessage() {
  unsigned long pctime;
  const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013

  if(Serial.find(TIME_HEADER)) {
     pctime = Serial.parseInt();
     if( pctime >= DEFAULT_TIME) { // check the integer is a valid time (greater than Jan 1 2013)
       setTime(pctime); // Sync Arduino clock to the time received on the serial port

time_t requestSync()
  return 0; // the time will be sent later in response to serial mesg

What do You find on Your display? What is happening, obvious not exactly what You want?
There is no code, no sketch, no script "out there" taht will do what You want. What ever code You pick up You will need to modify it to suit Your needs.
Use Serial.print to show what is happening inside. It's very useful.

I see time and date on the first line, somthing like this:

the link
but its only in the first line

my main goal is to have a countdown on the bottom line when its 30 seconds to the new year

Try and use Serial.print for debugging, print key variables along the road. You use "T" as a sync character. Did You send "T" and not the lower case "t"?
Ney Years eve events are coming closer… See You next year.

Try and use Serial.print for debugging, print key variables along the road. You use "T" as a sync character. Did You send "T" and not the lower case "t"?

Yes I did send the "T" and not the lower case "t",
and I am using Serial.print for debugging, not alot, only for the sync message so i won't forget, and BTW
this script is not mine it's an example that I changed a bit

Thats a good way to go, picking a sample code, an example code, and modify it.
During most of my professional time in programming I was thrown into large and unknown systems. During creation of new fynctions those temporary debug printouts very proceless as mostly there was nobody to ask questions.

Serial.print like "Now I'm at line this and that". "Waiting for this or that" are realy helpful. The task of Your code is not too complicated but is hard to read in such a small window. It's a well modularized code.

I did a Serial.print that says if needed to sync time and if it's complete
is it good?
if it's not complete it shows "sync not complete"
if its complete it shown sync complete and sends the time to the lcd

on a diffrent thread someone told that i should get a countdown script that starts a countdown with a button press and delete the button part of the code, but the question is how do i connect it to time example that i modified and make the timer start at 30 seconds to the new year?
my code is attached here:

sketch_dec30c.ino (2.4 KB)


Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.
Continued cross posting could result in a time out from the forum.

Could you take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.
Other general help and troubleshooting advice can be found here.

so sorry i will be careful next time
i did it beacause i ment to publish this post on the programming questions, i did it and then couldn't delete the other post

can someone please help me with the countdown? beacause i am in a hurry and i have half an hour left to work on this

can someone please help me with the countdown? because I am in a hurry and i have half an hour left to work on this


I think you need to put this non-trivial project aside and get it ready for the 2020-2021 new year. :roll_eyes:

"I am in a hurry" does not work at all well for coding. :astonished:

well i think you're right
thanks :slight_smile:

Enjoy the party.

Thank you.
Happy new year to everyone