Countdown Timer sketch for PCD8544 using Adafruit Library

Just wanted to post this for anyone else who is looking for a simple countdown timer to use with this lcd. Should be easily modifiable for use with others or to suit your specific needs.
I wanted to post this after looking all over for a simple countdown timer library or sketch and not finding one.

This is using the Adafruit library for PCD8544 GitHub - adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library: Arduino driver for PC8544, most commonly found in small Nokia 5110's
you also need the GFX library mentioned on that page GitHub - adafruit/Adafruit-GFX-Library: Adafruit GFX graphics core Arduino library, this is the 'core' class that all our other graphics libraries derive from

Here's the sketch

/*********************************************************************
This is an example sketch for a countdown timer using Nokia 5110 LCD
and adafruit library for the display

RWSDev.net
*********************************************************************/

#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>

// pin 7 - SCE
// pin 6 - RST
// pin 5 - D/C
// pin 4 - DN
// pin 3 - SCLK

// set timer position on lcd
int xPos = 16;
int yPos = 16;

int hours = 0;
int minutes = 0;
int seconds = 5;

Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);

void setup()   {
  display.begin();
  display.clearDisplay();   // clears the screen and buffer
  display.display();
}

void loop() {
  while (hours > 0 || minutes > 0 || seconds >= 0) {
    display.clearDisplay();   // clears the screen and buffer
    display.setContrast(30);
    display.setCursor(xPos, yPos);
    (hours < 10) ?display.print("0"):NULL;
    display.print(hours);
    display.print(":");
    (minutes < 10) ?display.print("0"):NULL;
    display.print(minutes);
    display.print(":");
    (seconds < 10) ?display.print("0"):NULL;
    display.print(seconds);
    display.display();
    stepDown();
    delay(1000);
  }
}

void stepDown() {
    if (seconds > 0) {
      seconds -= 1;
    } else {
      if (minutes > 0) {
        seconds = 59;
        minutes -= 1;
      } else {
        if (hours > 0) {
          seconds = 59;
          minutes = 59;
          hours -= 1;
        } else {
          trigger();
        }
      }
    }
}

void trigger() {
  display.clearDisplay();   // clears the screen and buffer
  display.setTextSize(2);
  display.setCursor(xPos, yPos);
  display.println("Boom");
  display.display();
}

Having trouble with this sketch.
error message for this line of code: (hours < 10) ?display.print("0"):NULL;

Countdown_timer:43: error: second operand to the conditional operator is of type 'void', but the third operand is neither a throw-expression nor of type 'void'

Can you help me out?

HB

Which IDE version, board, etc... are you using?
Also, if you've changed any of the code please include the code as well and I'll see if I can figure it out with you.

Jason

I'm using Arduino 0022 IDE in combination with the Arduino nano board with AT Mega 328. I've not changed the code except for the pin numbering as I had already connected the Nokia 5110 via a logic level converter this way for another sketch, which worked alright in the said configuration.
pin setup:
// pin 12 - SCE
// pin 11 - RST
// pin 10 - D/C
// pin 9 - DN
// pin 8 - SCLK
Thanks for looking into it. I'm new at Arduino and programming for that matter and these are my first steps so please bear with me.
Henk

i'm not sure but it may be a problem with the older version of the IDE you are using ... I've tested it on 1.0.1 and 1.5.2 and it works just fine. Try one of those and let me know if that works.

RWSDev:
i'm not sure but it may be a problem with the older version of the IDE you are using ... I've tested it on 1.0.1 and 1.5.2 and it works just fine. Try one of those and let me know if that works.

I got it working with IDE 1.5.2 but not after changing pin setting in your code. According to the standard Adafruit_PCD8544 library the pin direction are:

Adafruit_PCD8544(int8_t SCLK, int8_t DIN, int8_t DC, int8_t CS, int8_t RST)

Thanks for helping out. I'm hoping to use part of your code in other projects.
Henk