//
// FILE: demo_DHMS.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: demo
// DATE: 2017-07-16
// URL: http://forum.arduino.cc/index.php?topic=356253
// https://github.com/RobTillaart/CountDown
//
#include "CountDown.h"
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
CountDown CD;
int ledPin=5;
int buttonPin=4;
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
lcd.begin(16, 2);
lcd.setBacklight(1);
Serial.begin(115200);
//Serial.println(__FILE__);
//Serial.print("COUNTDOWN_LIB_VERSION: ");
//Serial.println(COUNTDOWN_LIB_VERSION);
// countdown 1 minute
// CD.start(0,0, 0, 15);
}
void loop()
{
static uint32_t last_remaining = 0;
buttonState = digitalRead(buttonPin);
if (buttonState!=lastButtonState) {
CD.start(0,0, 0, 15);
digitalWrite(ledPin, HIGH);
lcd.setCursor(0,0);
lcd.print("CD.start");
lcd.setCursor(1,0);
lcd.print(CD.remaining());
//Serial.println("CD.start");
}
lastButtonState = buttonState;
if (last_remaining != CD.remaining() || CD.remaining() == 0 ){
digitalWrite(ledPin, LOW);
last_remaining = CD.remaining();
}
/*
if (last_remaining != CD.remaining() || CD.remaining() == 0 )
{
if (buttonState!=lastButtonState) {
digitalWrite(ledPin, HIGH);
Serial.println("CD.start");
CD.start(0,0, 0, 15);
Serial.println();
last_remaining = CD.remaining();
}
}
*/
//Serial.print('\t');
//Serial.println(CD.remaining());
//lcd.setCursor(1,0);
//lcd.println('\t');
//lcd.println(CD.remaining());
delay(250);
}
// -- END OF FILE --